Class Field

Field of a model.

class Field(params)
Arguments:
  • params (Object) – Parameters for this field
  • params.primaryKey (Boolean) – This field is the primary key.
  • params.unique (Boolean) – This field is unique.
  • params.null (Boolean) – This field can be null.
  • params.choices (Boolean) – Array of [dbValue, displayValue] This field can hold exclusively values from choices.

See also

Model

Methods

getParams

Returns the params object of this field.

Field.prototype.getParams()

toJs

Converts the value, that was fetched from a database query result, to its JavaScript equivalent. Callback is then called with the converted instance.

Field.prototype.toJs(value, callback)
Arguments:
  • value
  • callback

toSql

Returns value as SQL formatted string

Field.prototype.toSql(value)
Arguments:
  • value

validate

If value is valid returns true else returns an error msg string

Field.prototype.validate(value)
Arguments:
  • value