我希望实现IS-A关系。我读过https://sequelize.org/master/manual/associations.html#one-to-one-associations并认为应该使用一个属于关系。例如,假设我有一位IS-A Doctor的骨科医师。这是正确的方法吗?
Orthopedic.belongsTo(models.Doctor,{
name: 'id',type: DataTypes.INTEGER,primaryKey: true
});
模型:
module.exports = (sequelize,DataTypes) => {
const Orthopedic = sequelize.define('Orthopedic',{
specialization: {
type: DataTypes.STRING,},});
return Orthopedic;
};
module.exports = (sequelize,DataTypes) => {
const Doctor = sequelize.define('Doctor',{
name: {
type: DataTypes.STRING,age: {
type: DataTypes.INTEGER,});
return Doctor;
};