Fields

Fields

Static model field builder.

note: "one-or-more" is handled as `array: true` in the options, rather than being its own type of model field. (On the schema side this is the __meta.array:true property)

All fields can be passed an options object that supports arbitrary keywords, with some exceptions that are used by the schema system itself:


  {
    required: boolean,
    default: any value,
    choices: array of possible values,
    configurable: boolean,
    debug: boolean,
  }

Methods

(static) boolean(options) → {ModelField}

Source:
Model field definition for boolean values.
Parameters:
Name Type Description
options Object an options object, see above.
Returns:
Type
ModelField

(static) choice(choices, options) → {ModelField}

Source:
Parameters:
Name Type Description
choices Array.<any> Array of valid values for this field.
options Object an options object, see above.
Returns:
Type
ModelField

(static) model(model, options) → {ModelField}

Source:
Parameters:
Name Type Description
model Model
options Object an options object, see above.
Returns:
Type
ModelField

(static) number(options) → {ModelField}

Source:
Parameters:
Name Type Description
options Object an options object, see above.
Returns:
Type
ModelField

(static) string(options) → {ModelField}

Source:
Parameters:
Name Type Description
options Object an options object, see above.
Returns:
Type
ModelField