完善保险端前后端和养殖端小程序
This commit is contained in:
@@ -85,21 +85,21 @@ const CattleBatch = sequelize.define('CattleBatch', {
|
||||
comment: '批次设置表'
|
||||
});
|
||||
|
||||
// 定义关联关系
|
||||
CattleBatch.associate = (models) => {
|
||||
// 批次属于农场
|
||||
CattleBatch.belongsTo(models.Farm, {
|
||||
foreignKey: 'farmId',
|
||||
as: 'farm'
|
||||
});
|
||||
// 关联关系已在 models/index.js 中定义
|
||||
// CattleBatch.associate = (models) => {
|
||||
// // 批次属于农场
|
||||
// CattleBatch.belongsTo(models.Farm, {
|
||||
// foreignKey: 'farmId',
|
||||
// as: 'farm'
|
||||
// });
|
||||
|
||||
// 批次与动物的多对多关系
|
||||
CattleBatch.belongsToMany(models.Animal, {
|
||||
through: 'cattle_batch_animals',
|
||||
foreignKey: 'batch_id',
|
||||
otherKey: 'animal_id',
|
||||
as: 'animals'
|
||||
});
|
||||
};
|
||||
// // 批次与动物的多对多关系
|
||||
// CattleBatch.belongsToMany(models.Animal, {
|
||||
// through: 'cattle_batch_animals',
|
||||
// foreignKey: 'batch_id',
|
||||
// otherKey: 'animal_id',
|
||||
// as: 'animals'
|
||||
// });
|
||||
// };
|
||||
|
||||
module.exports = CattleBatch;
|
||||
|
||||
Reference in New Issue
Block a user