Model.addField >= 1.0.0
Purpose
Add a field to this model's schema
Syntax
Model.addField
(
Stringname
Stringtype
Objectoptions
);
Parameters
name
- The name of the field to add
type
- The type of the field, should map to a class in the Alchemy.Field namespace
options
- Extra options (like `array` or `unique`)
Return values
Object
Examples
Adding a new field in a constitutor function
var Person = Function.inherits('Alchemy.Model', function Person(options) {
Person.super.call(this, options);
});
Person.constitute(function addFields() {
// The firstname of this person
this.addField('firstname', 'String');
// The lastname of this person
this.addField('lastname', 'String');
});
Comments