2
这是我Buildings
如何获得模型关联数组中sequelize
var Buildings = sequelize.define('buildings', buildingsDefinition,
{
timestamps: true,
underscored: false,
paranoid: true,
indexes: [
{ fields: ['accId']}
],
engine: 'innodb',
classMethods:{
associate:function(models){
this.hasMany(models.Rooms, {
as: 'Rooms',
foreignKey: 'buildingId',
onUpdate: 'NO ACTION',
onDelete: 'NO ACTION',
constraints: false
})
}
}
}
);
在路由模式,如何获取的关联数组这种模式?
期望的结果,是这样的:
[
{'Rooms':
{
as: 'Rooms',
foreignKey: 'buildingId',
onUpdate: 'NO ACTION',
onDelete: 'NO ACTION',
constraints: false
}
}
]
喜欢的东西Models.Buildings.classMethods