CreationOptional<T>: T extends null | undefined
    ? T
    : T & {
        [CreationAttributeBrand]?: true;
    }

This is a Branded Type. You can use it to tag attributes that can be omitted during Model Creation. Use it on attributes that have a default value or are marked as autoIncrement.

For use with InferCreationAttributes.

Type Parameters

  • T

Example

class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
@Attribute(DataTypes.INTEGER)
@PrimaryKey
@AutoIncrement
declare internalId: CreationOptional<number>;

@Attribute(DataTypes.STRING)
@Default('John Doe')
declare name: CreationOptional<string>;
}