• Preparing search index...
  • The search index is not available
Documentation
  • Documentation
  • @sequelize/core
  • decorators-legacy
  • PrimaryKey

Function PrimaryKey

  • PrimaryKey(): PropertyOrGetterDescriptor
  • The @PrimaryKey decorator is used to make an attribute a primary key, it is a shortcut for setting the primaryKey option of the Attribute decorator to true.

    Returns PropertyOrGetterDescriptor

    Example

    class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
    @Attribute(DataTypes.INTEGER)
    @PrimaryKey
    declare id: number;
    }
    • Defined in packages/core/src/decorators/legacy/attribute.ts:167
  • PrimaryKey(options): PropertyOrGetterDescriptor
  • The @PrimaryKey decorator is used to make an attribute a primary key, it is a shortcut for setting the primaryKey option of the Attribute decorator to true.

    Parameters

    • options: boolean

    Returns PropertyOrGetterDescriptor

    Example

    class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
    @Attribute(DataTypes.INTEGER)
    @PrimaryKey
    declare id: number;
    }
    • Defined in packages/core/src/decorators/legacy/attribute.ts:167
  • PrimaryKey(target, propertyName, propertyDescriptor?): void
  • The @PrimaryKey decorator is used to make an attribute a primary key, it is a shortcut for setting the primaryKey option of the Attribute decorator to true.

    Parameters

    • target: Object
    • propertyName: string | symbol
    • Optional propertyDescriptor: PropertyDescriptor

    Returns void

    Example

    class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
    @Attribute(DataTypes.INTEGER)
    @PrimaryKey
    declare id: number;
    }
    • Defined in packages/core/src/decorators/legacy/attribute.ts:167

Settings

Member Visibility

Theme

Documentation
  • Loading...

Generated using TypeDoc