Sails.js Sails mongodb添加条件。填充

Sails.js Sails mongodb添加条件。填充,sails.js,Sails.js,这里是新手,在使用.populate-in-sails js时有没有添加标准的方法。或者甚至有可能这样做 前 请说点什么 谢谢试试: Model.find().populate('toPopulate', where: { id: [1,2,3,4] } ).exec(console.log); @mdunisch的答案几乎是正确的,只需要包含@sgress454的修复。下面是一个如何在populate中添加过滤器的工作示例 Model.find().populate('toPop

这里是新手,在使用.populate-in-sails js时有没有添加标准的方法。或者甚至有可能这样做

请说点什么

谢谢

试试:

Model.find().populate('toPopulate',
where: {
    id: [1,2,3,4]
  }
).exec(console.log);

@mdunisch的答案几乎是正确的,只需要包含@sgress454的修复。下面是一个如何在populate中添加过滤器的工作示例

Model.find().populate('toPopulate',
    {where: {id: [1,2,3,4]}}).exec(console.log);

您也可以在不使用
where

Model.find().populate('toPopulate', {id: [1,2,3,4]}).exec(console.log);

如果你能提供一个文档或其他东西的链接,这样OP就可以学会搜索了,那就太好了。谢谢你的回复,但是在where后面的冒号部分出现了一个错误。不过还是要谢谢你。整个
where
子句需要用大括号括起来;那么这应该行得通。
Model.find().populate('toPopulate', {id: [1,2,3,4]}).exec(console.log);