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