这样写代码会报错:
PostModel.findAsync({author:author}).populateAsync('author')
.then(function (posts) {
res.render('posts', {
posts: posts
});
})
.catch(next);
错误为:
bluebird这个库的populate是怎么用的呢?
PostModel.findis not a callback method or even asynchronous soPostModel.findAsyncdoesn't make sense. You shouldn't need to promisify your own classes you should just have your clasess to return promises to begin with.If you have promisified mongoose somewhere:
You can do
populate is not a function of bluebird, it's one of mongooseReference from here