【发布时间】:2019-03-20 14:52:59
【问题描述】:
我正在尝试使用 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"]]
});
提前致谢!!
【问题讨论】:
标签: node.js sequelize.js