AttributeDefinition

type AttributeDefinition = type AttributeDefinition = TypeDefinition | AttributeOptions;

Defines an attribute, it can be either a TypeDefinition or an AttributeOptions. If an TypeDefinition is used, the default value is used for all the not specified AttributeOptions attributes.

AttributeOptions

interface AttributeOptions {
    defaultValue?: Natural;
    fieldName?: string;
    notNull?: boolean;
    type: TypeDefinition;
    unique?: boolean;
}

Specifies the options of an attribute.

AttributeOptions.defaultValue

  • default: undefined

If specified, defines the default value of the field at database level. See Entries initialization for details.

AttributeOptions.fieldName

  • default: undefined

If specified, defines the name of the field at database level, otherwise the field has the same name of the attribute. This option is useful when a fields needs to have a reserved name.

AttributeOptions.notNull

  • default: undefined

If true, specifies to set a NOT NULL CONSTRAIN on the field at database level.

AttributeOptions.type

  • required

Specifies the type of the field at database level. Accepts a TypeDefinition.

AttributeOptions.unique

  • default: undefined

If true, specifies to set a UNIQUE CONSTRAIN on the field at database level.

AttributesDefinition

type AttributesDefinition = { [key: string]: AttributeDefinition };

Defines the attributes of a Model. It is an Object where each key is the name of the attribute and the relative AttributeDefinition value is the definition of the attribute.