sails模型查询findOne按id从assosiation搜索

时间:2015-11-04 04:37:59

标签: node.js sails.js waterline

如何查询findOne以通过风帆上的assosiation来搜索id?

我的示例模型:

1. model Stream.js

    module.exports = {
         attributes: {
           title: { type: "string" },
           author: { model: "media_account" } 
         },
         schema: true
       };

 2. model Media_account.js

    module.exports = {
      attributes: {
        name: { type: "string" },
        streams: {
          collection: 'stream',
          via: 'author'
        }
       },
       schema: true

      };

如何让所有溪流成为最佳作者? 我正在尝试下面的查询,但总是返回空数组

Stream.find({author: "12345"});
如果我通过mongo控制台检查,那么我的数据库流上的作者“12345”是退出的

db.stream.find({author: Objectid("12345")});   

result :

[{
  id: "1ddd2323ef",
  title: "haha",
  author: "12345"
}]

0 个答案:

没有答案