The simplest way to use it is to pass a data type as the parameter:
class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
@Attribute(DataTypes.STRING)
declare firstName: string | null;
}
@Attribute
also accepts an option bag, index~AttributeOptions, which allows you to configure all available attribute definition options.
class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
@Attribute({
type: DataTypes.STRING,
allowNull: false,
})
declare firstName: string;
}
The
@Attribute
decorator is used to add an attribute to a model. It is used on an instance property.