AttributeOptions
interface AttributeOptions<T, N extends boolean> {
defaultValue?: T;
fieldName?: string;
notNull?: N;
unique?: boolean;
}
Specifies the options of an attribute. Passed to type functions (e.g. sedentary.Int, sedentary.VarChar).
AttributeOptions.defaultValue
default:
undefined
If specified, defines the default value of the field at database level. See Entries initialization for the distinction between database-level and JavaScript-level initialization.
AttributeOptions.fieldName
default: same as attribute name
If specified, defines the name of the field at database level. Useful when a field needs a Reserved names mapping.
Reserved names
These names cannot be used as attribute names: attr2field, attributeName, cancel, class, construct,
constructor, defaultValue, fieldName, foreignKeys, load, modelName, name, postCommit,
postLoad, postRemove, postSave, preCommit, preLoad, preRemove, preSave, primaryKey,
prototype, remove, save, tableName, type, unique.
AttributeOptions.notNull
default:
false
If true, specifies a NOT NULL constraint on the field at database level. See Entries initialization for the distinction between database-level and JavaScript-level initialization.
AttributeOptions.unique
default:
false
If true, specifies a UNIQUE constraint on the field at database level. Required for attributes used as
Foreign keys targets.
AttributeOptionsSize
interface AttributeOptionsSize<T, N extends boolean> extends AttributeOptions<T, N> {
size?: number;
}
Extends AttributeOptions with a size option. Used by sedentary.Int,
sedentary.Float, sedentary.VarChar.
AttributesDefinition
type AttributesDefinition = { [key: string]: Type };
Defines the attributes of a Model. It is an Object where each key is the name of the attribute and
the value is the result of calling a type function (e.g. db.Int(), db.VarChar({ size: 255 })).