如何通过sails.js中的查询参数select性地填充水线关联

默认情况下,当相应的API路由命中时,sails将填充模型中的所有关系。 有谁知道是否有可能切换此function? 如果我正在使用一对多关联,则出于性能原因进行所有项目列表时,我可能不想填充关联。 但是,当查看一个单一的项目,这将是很好的完成人口。

例如,说一张票可以有很多评论。 提取案例列表时,我不在意这些意见,但在查看特定案例时,这一点很重要。 我猜测它是如何工作的,但是失败了:

localhost:1337/tickets?populate=false 

更新

我在balderdashy / sails#1695中实现了上述function。 唯一的变化是你有select地select使用哪些关联来填充:

 localhost:1337/tickets?populate=[] // Don't populate anything localhost:1337/tickets?populate=[comments] // Only populate comments 

这将覆盖在蓝图configuration中populate任何内容。

你只需要通过comma分隔你的assosiactions,就像这样:

 localhost:1337/tickets?populate=comments,owner&SOME_OTHER_PARAMS