当我尝试合并hasMany
和belongsTo
时遇到错误。当我尝试删除包含中的belongTo
时,它可以正常工作。
include: [
//hasMany user role
{
model: UsersRoleModel
},
//taxonomy belong to user
{
model: TaxonomyModel, as: 'job_title',
attributes: ['title']
}
]
UsersModel.belongsTo(TaxonomyModel, {as: 'job_title', foreignKey: 'job_title_id'});`enter code here`
UsersModel.hasMany(UsersRoleModel, { foreignKey: 'user_id' });