我正在尝试使用Sequelize对以下架构的结果进行排序。但我遇到类似Unable to find a valid association for the model, 'UserProject'
请在下面找到我的代码,实际上,我想按UserProject.role
UserProject = sequelize.define('user_project', { role: Sequelize.STRING});
User.belongsToMany(Project, { through: UserProject });
User.findAll({
include: {
required: true,
through: {
attributes: [],
model: UserProject
},
model:Project,
order: [[{ model: UserProject}, "role", "ASC"]]
});
提前谢谢!
答案 0 :(得分:0)
该怎么办?
User.findAll({
include: {
required: true,
through: {
attributes: [],
model: UserProject
},
model:Project
},
order: [[UserProject, "role", "ASC"]]
});