【问题标题】:Sailsjs/Waterline : How to populate model after Model.Query()?Sailsjs/Waterline:如何在 Model.Query() 之后填充模型?
【发布时间】:2015-03-25 10:18:25
【问题描述】:

我正在使用 bluebird 库并承诺,如何在 Model.Query() 之后填充模型?我的以下代码是错误的:

var Promise = require('bluebird');
var pmodel = Promise.promisify(someModel.query);

pmodel
 .("custom sql")
 .populate("attributes_id")
 .then(function(datas){
  console.log(datas)
  })

如何做到这一点?谢谢。

【问题讨论】:

    标签: sails.js waterline


    【解决方案1】:

    一种方法是

    pmodel
    .("custom sql", function(err, datas){
        // here you will have the data and you can add promises to the following line
        pmodel.find(.pluck(datas, 'id')).exec();
      })
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-20
      • 1970-01-01
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      • 2019-09-01
      • 2015-08-05
      • 2016-01-16
      相关资源
      最近更新 更多