【发布时间】:2021-06-24 05:51:11
【问题描述】:
我需要将外键添加到引用健身房 id 的用户表中, 什么是正确的语法?
export class User extends Model<User> {
// user properties:
@PrimaryKey
@AutoIncrement
@Column(DataType.INTEGER)
public id: number;
@AllowNull(false)
@Column(DataType.STRING)
public first_name: string;
// here i need to reference the gym_id to the id from the gym table:
@AllowNull(false)
@Column(DataType.INTEGER)
// @ForeignKey(Gym.id)
public gym_id: number;
}
【问题讨论】:
标签: node.js database postgresql sequelize.js sequelize-typescript