|
@ -27,7 +27,7 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const { User, Department } = dc.models; |
|
|
const { User, Department } = dc.models; |
|
|
|
|
|
// 定义外键
|
|
|
User.belongsTo(Department, { foreignKey: 'departmentId', targetKey: 'id' }); |
|
|
User.belongsTo(Department, { foreignKey: 'departmentId', targetKey: 'id' }); |
|
|
Department.hasMany(User, { foreignKey: 'departmentId', sourceKey: 'id' }); |
|
|
Department.hasMany(User, { foreignKey: 'departmentId', sourceKey: 'id' }); |
|
|
}; |
|
|
}; |
|
|