By default we export an instance of Plaster object.
Clients can create a new instances using the constructor.
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
default schema options
|
Example
var plaster = require('plaster');
var schema = plaster.schema({ name: String });
var Cat = plaster.model('Cat', schema);
var kitty = new Cat({ name: 'Zildjian' });
Members
-
Expose the Model class
Example
var schema = plaster.schema({ name: String });
var Cat = plaster.model('Cat', schema);
var kitty = new Cat({ name: 'Zildjian' });
console.log(kitty insanceof plaster.Model); // true -
ModelArrayModelArray
-
Expose the ModelArray class
-
Expose Plaster constructor so clients can create new instances.
-
Expose the Schema class
Example
var schema = new plaster.Schema({ name: String});
Methods
-
Get option.
Returns:
Type Description * Option value -
Returns the model given the name.
Name Type Description name
Returns:
Type Description * -
Creates a model from a schema.
Name Type Description name
String name of the model.
schema
Schema instance
options
Object options
Name Type Description freeze
Boolean to freeze model. See
Object.freeze
. Default:true
-
Returns an array of model names created on this instance of Plaster.
Returns:
Type Description Array Array of model names registered. -
Creates a schema. Prefer to use this over Schema constructor as this will pass along Plaster config settings.
Name Type Description descriptor
Object the schema descriptor
options
Object Schema options
Returns:
Type Description Object created Schema instance -
Sets Plaster config options
Name Type Description key
String the option key
value
* option value