[英]Sequelize use included model in where-object
I'm using Sequelize.js with nodejs on a server 我使用Sequelize.js与服务器上的NodeJS
It is possible to eager load associated models like this: 可能希望像这样加载相关的模型:
User.findAll({ include: [ Task ] })
Given this example, is there a way to access the Tasks properties directly in a where-object like so? 给定此示例,是否有办法像在where对象中那样直接访问Tasks属性 ?
User.findAll({where:{Task.getId() = 1}},{ include: [ Task ] })
Or can this only be achieved by a seperate functioncall? 还是只能通过单独的函数调用来实现?
You can convert the include to an object with model and where properties 您可以将包含转换为具有模型和where属性的对象
User.findAll({
include: [ {
model: Task
where: { id: 1 }
}]
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.