【发布时间】:2017-02-03 19:45:34
【问题描述】:
是否有任何可能的方法来重现此查询
select table2.node_id as id, table2.client_id as clientId, table1.collection_id as collectionId from table1 inner join table2 on table2.primary_collection_id = table1.collection_id
在sequelize orm中?
我定义了hasOne 和belongsTo 关系并尝试这样做:
return Models.FileModel.findAll({
include: [
{ model: Models.NodeModel, required: true}
]
});
但我的inner join 条件不正确:
inner join table2 on table2.node_id = table1.collection_d
需要将table2.node_id替换为table2.primary_collection_id
【问题讨论】:
-
请包含您设置表之间关系的代码。
标签: mysql node.js sequelize.js