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.
@PrimaryKey
primaryKey
class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> { @Attribute(DataTypes.INTEGER) @PrimaryKey declare id: number;} Copy
class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> { @Attribute(DataTypes.INTEGER) @PrimaryKey declare id: number;}
Optional
The
@PrimaryKeydecorator is used to make an attribute a primary key, it is a shortcut for setting theprimaryKeyoption of the Attribute decorator to true.Example