Options
All
  • Public
  • Public/Protected
  • All
Menu

Column options for the model schema attributes

see

Attributes

Hierarchy

Index

Properties

Optional allowNull

allowNull: boolean

If false, the column will have a NOT NULL constraint, and a not null validation will be run before an instance is saved.

Optional autoIncrement

autoIncrement: boolean

Is this field an auto increment field

Optional comment

comment: string

Comment for the database

Optional defaultValue

defaultValue: any

A literal default value, a JavaScript function, or an SQL function (see sequelize.fn)

Optional field

field: string

If set, sequelize will map the attribute name to a different name in the database

Optional get

get: function

Provide a custom getter for this column. Use this.getDataValue(String) to manipulate the underlying values.

Type declaration

    • (): any
    • Returns any

Optional onDelete

onDelete: string

What should happen when the referenced key is deleted. One of CASCADE, RESTRICT, SET DEFAULT, SET NULL or NO ACTION

Optional onUpdate

onUpdate: string

What should happen when the referenced key is updated. One of CASCADE, RESTRICT, SET DEFAULT, SET NULL or NO ACTION

Optional primaryKey

primaryKey: boolean

Primary key flag

Optional references

An object with reference configurations

Optional set

set: function

Provide a custom setter for this column. Use this.setDataValue(String, Value) to manipulate the underlying values.

Type declaration

    • (val: any): void
    • Parameters

      • val: any

      Returns void

type

type: string | DataTypeAbstract

A string or a data type

Optional unique

unique: boolean | string | object

If true, the column will get a unique constraint. If a string is provided, the column will be part of a composite unique index. If multiple columns have the same string, they will be part of the same unique index

Optional validate

An object of validations to execute for this column every time the model is saved. Can be either the name of a validation provided by validator.js, a validation function provided by extending validator.js (see the DAOValidator property for more details), or a custom validation function. Custom validation functions are called with the value of the field, and can possibly take a second callback argument, to signal that they are asynchronous. If the validator is sync, it should throw in the case of a failed validation, it it is async, the callback should be called with the error text.

Optional values

values: string[]

Usage in object notation

sequelize.define('model', {
    states: {
      type:   Sequelize.ENUM,
      values: ['active', 'pending', 'deleted']
    }
  })

Generated using TypeDoc