• The @AutoIncrement decorator is used to make an attribute auto-increment, it is a shortcut for setting the autoIncrement option of the Attribute decorator to true.

    Some dialects require the field to be a primary key.

    Returns PropertyOrGetterDescriptor

    Example

    class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
    @Attribute(DataTypes.INTEGER)
    @PrimaryKey
    @AutoIncrement
    declare id: number;
    }
  • The @AutoIncrement decorator is used to make an attribute auto-increment, it is a shortcut for setting the autoIncrement option of the Attribute decorator to true.

    Some dialects require the field to be a primary key.

    Parameters

    • options: boolean

    Returns PropertyOrGetterDescriptor

    Example

    class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
    @Attribute(DataTypes.INTEGER)
    @PrimaryKey
    @AutoIncrement
    declare id: number;
    }
  • The @AutoIncrement decorator is used to make an attribute auto-increment, it is a shortcut for setting the autoIncrement option of the Attribute decorator to true.

    Some dialects require the field to be a primary key.

    Parameters

    Returns void

    Example

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