Options
All
  • Public
  • Public/Protected
  • All
Menu

A convenience class holding commonly used data types. The datatypes are used when definining a new model using Sequelize.define, like this:

sequelize.define('model', {
  column: DataTypes.INTEGER
})

When defining a model you can just as easily pass a string as type, but often using the types defined here is beneficial. For example, using DataTypes.BLOB, mean that that column will be returned as an instance of Buffer when being fetched by sequelize.

Some data types have special properties that can be accessed in order to change the data type. For example, to get an unsigned integer with zerofill you can do DataTypes.INTEGER.UNSIGNED.ZEROFILL. The order you access the properties in do not matter, so DataTypes.INTEGER.ZEROFILL.UNSIGNED is fine as well. The available properties are listed under each data type.

To provide a length for the data type, you can invoke it like a function: INTEGER(2)

Three of the values provided here (NOW, UUIDV1 and UUIDV4) are special default values, that should not be used to define types. Instead they are used as shorthands for defining default values. For example, to get a uuid field with a default value generated following v1 of the UUID standard:

sequelize.define('model', {
  uuid: {
    type: DataTypes.UUID,
    defaultValue: DataTypes.UUIDV1,
    primaryKey: true
  }
})

Hierarchy

Index

Properties

ABSTRACT

ARRAY

BIGINT

BLOB

BOOLEAN

CHAR

DATE

DATEONLY

DECIMAL

DOUBLE

DOUBLE PRECISION

DOUBLE PRECISION: DataTypeDouble

ENUM

FLOAT

GEOMETRY

HSTORE

INTEGER

JSON

JSONB

NONE

NOW

NUMBER

NUMERIC

RANGE

REAL

STRING

TEXT

TIME

UUID

UUIDV1

UUIDV4

VIRTUAL

Generated using TypeDoc