A column storing a unique universal identifier. Use with sql.uuidV1 or sql.uuidV4 for default values.

Fallback policy: If this type is not supported, it will be replaced by a string type with a CHECK constraint to enforce a GUID format.

const User = sequelize.define('User', {
id: {
type: DataTypes.UUID.V4,
defaultValue: sql.uuidV4,
},
});

Hierarchy (View Summary)

Constructors

Properties

options: UuidOptions
usageContext: undefined | DataTypeUseContext

Where this DataType is being used.

Accessors

Methods

  • Called when a value is retrieved from the Database, and its DataType is specified. Used to normalize values from the database.

    Note: It is also possible to do an initial parsing of a Database value using AbstractDialect#registerDataTypeParser. That normalization uses the type ID from the database instead of a Sequelize Data Type to determine which parser to use, and is called before this method.

    Parameters

    • value: unknown

      The value to parse.

    Returns unknown

  • Converts a JS value to a value compatible with the connector library for this Data Type. Unlike escape, this value does not need to be escaped. It is passed separately to the database, which will handle escaping.

    Parameters

    • value: string

      The value to convert.

    Returns unknown