diff --git a/docs/api.md b/docs/api.md index 71a6e8b3..0bbaca35 100644 --- a/docs/api.md +++ b/docs/api.md @@ -113,6 +113,13 @@ The following is an example of an object containing two `Model` definitions: "lo Define a `Model` and export it for use by remote clients. +**definition** + + - `public` - **default: true** attach the `Model` to the app and export its methods to clients + - `dataSource` - **required** the name of the `DataSource` to attach the `Model` to + +**Example** + ```js // declare a DataSource app.boot({ diff --git a/lib/application.js b/lib/application.js index 590b83ab..29cb46b7 100644 --- a/lib/application.js +++ b/lib/application.js @@ -67,6 +67,7 @@ app.model = function (Model, config) { return; } var modelName = Model; + config = config || {}; assert(typeof modelName === 'string', 'app.model(name, config) => "name" name must be a string'); Model = @@ -74,7 +75,9 @@ app.model = function (Model, config) { this.models[classify(modelName)] = this.models[camelize(modelName)] = modelFromConfig(modelName, config, this); - this.model(Model); + if(config.public !== false) { + this.model(Model); + } return Model; }