Skip to content

postgrelize / AttributeOptions

Type Alias: AttributeOptions<M> ​

AttributeOptions<M> = Readonly<{ allowNull?: boolean; autoIncrement?: boolean; comment?: string; defaultValue?: unknown; field?: string; generated?: GeneratedColumn; identity?: "always" | "byDefault"; onDelete?: string; onUpdate?: string; primaryKey?: boolean; references?: string | ReferenceOptions; type: DataTypeInput; unique?: boolean | string | UniqueOptions; validate?: AttributeValidateOptions; values?: readonly string[]; get?(this): unknown; set?(this, value): void; }>

Defined in: src/model/attribute-options.ts:89

Column definition of a model attribute (Sequelize v6 ModelAttributeColumnOptions).

sync() turns these into CREATE TABLE column definitions; validators run before INSERT / UPDATE.

Type Parameters ​

M ​

M extends AnyModel = AnyModel

See ​

Model.init

Example ​

ts
const attr: AttributeOptions = {
  type: DataTypes.STRING,
  allowNull: false,
  unique: true,
  validate: { isEmail: true },
};

Released under the MIT License.