model.populate does not return an ES6 promise even if mongoose.Promise is set
Is it the expected behaviour that model.populate does not return the Promise as defined in mongoose.Promise
var mongoose = require('mongoose');
mongoose.Promise = require('bluebird');
// ...
User.populate(docs, {path: 'company'})
.then(console.log)
.catch(console.errors);
This piece of code throw the error:
TypeError: User.populate(...).then(...).catch is not a function
+1 exec not return ES6 promise too =( findById(...).exec(...).then(...).catch is not a function
@MniD are you using mongoose 4.x? Are you also setting mongoose.Promise? We have tests in place to make sure exec returns ES6-friendly promises if configured to do so
Model.find(...).populate().exec() returns a promise now but the method does not (tested in mongoose 4.5.8):
var document = new Model(...)
document.populate(...) // does not return a promise
@ohjames expected behavior, use .execPopulate() . the populate() method returns the document so you can chain populate() calls. This issue refers to Model.populate() rather than document.populate()