0

I'm use bluebird library and promise, How to populate model after Model.Query()? my following code is error:

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

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

How to do this? thank.

1 Answers1

0

One way to do this is

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();
  })

Hope it helped

Sahan
  • 1,422
  • 2
  • 18
  • 33