Class: Model

Model(data)

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,

  1. a new Model instance will be created, and properties in data will be copied base accordingly.
  2. all input=false properties will be ignored.
  3. for method=insert, only updatable properties will be copied and validated
  4. for other method, all primary key properties will be copied and validated as well
  5. 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: