Merge pull request #1379 from strongloop/ref/modelbuilder-apidocs

ModelBuilder API Doc Touchup
This commit is contained in:
Kevin Delisle 2017-05-23 10:38:57 -04:00 committed by GitHub
commit a007c5a3fa
1 changed files with 12 additions and 7 deletions

View File

@ -71,7 +71,7 @@ function isModelClass(cls) {
* *
* @param {String} name The model name * @param {String} name The model name
* @param {Boolean} forceCreate Whether the create a stub for the given name if a model doesn't exist. * @param {Boolean} forceCreate Whether the create a stub for the given name if a model doesn't exist.
* @returns {*} The model class * @returns {ModelClass} The model class
*/ */
ModelBuilder.prototype.getModel = function(name, forceCreate) { ModelBuilder.prototype.getModel = function(name, forceCreate) {
var model = this.models[name]; var model = this.models[name];
@ -116,7 +116,7 @@ ModelBuilder.prototype.getModelDefinition = function(name) {
* @param {Object} properties Hash of class properties in format `{property: Type, property2: Type2, ...}` or `{property: {type: Type}, property2: {type: Type2}, ...}` * @param {Object} properties Hash of class properties in format `{property: Type, property2: Type2, ...}` or `{property: {type: Type}, property2: {type: Type2}, ...}`
* @param {Object} settings Other configuration of class * @param {Object} settings Other configuration of class
* @param {Function} parent Parent model * @param {Function} parent Parent model
* @return newly created class * @return {ModelClass} The class constructor.
* *
*/ */
ModelBuilder.prototype.define = function defineClass(className, properties, settings, parent) { ModelBuilder.prototype.define = function defineClass(className, properties, settings, parent) {
@ -444,7 +444,7 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett
* *
* - Any * - Any
* - `{replace: true}` (default): child replaces the value from parent * - `{replace: true}` (default): child replaces the value from parent
* - assignin `null` on child setting deletes the inherited setting * - assigning `null` on child setting deletes the inherited setting
* *
* - Arrays: * - Arrays:
* - `{replace: false}`: unique elements of parent and child cumulate * - `{replace: false}`: unique elements of parent and child cumulate
@ -763,7 +763,10 @@ function hiddenProperty(where, property, value) {
} }
/** /**
* Get the schema name * Get the schema name. If no parameter is given, then an anonymous model name
* is generated and returned.
* @param {string=} name The optional name parameter.
* @returns {string} The schema name.
*/ */
ModelBuilder.prototype.getSchemaName = function(name) { ModelBuilder.prototype.getSchemaName = function(name) {
if (name) { if (name) {
@ -780,7 +783,8 @@ ModelBuilder.prototype.getSchemaName = function(name) {
/** /**
* Resolve the type string to be a function, for example, 'String' to String. * Resolve the type string to be a function, for example, 'String' to String.
* Returns {Function} if the type is resolved * Returns {Function} if the type is resolved
* @param {String} type The type string, such as 'number', 'Number', 'boolean', or 'String'. It's case insensitive * @param {String} type The type string, such as 'number', 'Number', 'boolean',
* or 'String'. This parameter is case insensitive.
*/ */
ModelBuilder.prototype.resolveType = function(type) { ModelBuilder.prototype.resolveType = function(type) {
if (!type) { if (!type) {
@ -832,7 +836,8 @@ ModelBuilder.prototype.resolveType = function(type) {
* 3. A list of property definitions (anonymous) * 3. A list of property definitions (anonymous)
* *
* @param {*} schemas The schemas * @param {*} schemas The schemas
* @returns {Object} A map of model constructors keyed by model name * @returns {Object.<string, ModelClass>} A map of model constructors keyed by
* model name.
*/ */
ModelBuilder.prototype.buildModels = function(schemas, createModel) { ModelBuilder.prototype.buildModels = function(schemas, createModel) {
var models = {}; var models = {};
@ -887,7 +892,7 @@ ModelBuilder.prototype.buildModels = function(schemas, createModel) {
* @param {String} name The model name * @param {String} name The model name
* @param {Object} json The JSON object * @param {Object} json The JSON object
* @param {Object} options The options * @param {Object} options The options
* @returns {} * @returns {ModelClass} The generated model class constructor.
*/ */
ModelBuilder.prototype.buildModelFromInstance = function(name, json, options) { ModelBuilder.prototype.buildModelFromInstance = function(name, json, options) {
// Introspect the JSON document to generate a schema // Introspect the JSON document to generate a schema