Add public flag checking
This commit is contained in:
parent
9eb44bdb59
commit
ec58237f8a
|
@ -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({
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue