new Model(data)
Parameters:
Name | Type | Description |
---|---|---|
data |
object |
- Source:
Example
var user = new User({ nick: 'foo', age: 22 });
Members
(static) $entity
Model's definition
- Source:
(static) $name
Model's name
- Source:
Methods
(static) input(options) → {Promise.<Model>}
Accept user input data(like post from browser), convert data type and run validation,
- a new Model instance will be created, and properties in data will be copied base accordingly.
- all input=false properties will be ignored.
- for method=insert, only updatable properties will be copied and validated
- for other method, all primary key properties will be copied and validated as well
- if convertion/validation fail, a TypeError/Error with code/description properties will be shipped with rejection. you can customize that err by pass Model~newErr callback
Parameters:
Name | Type | Description |
---|---|---|
options |
InputOptions |
- Source:
Returns:
- Type
- Promise.<Model>
validate(method, err)
Validate current instance
Parameters:
Name | Type | Description |
---|---|---|
method |
string | validate purpose: update/insert |
err |
newErr | customize err instance |
- Source: