我想同步运行此代码,如何使用promises执行此操作?
Predefined (,separated)
找到它们之后运行:
var homePosts = {};
Post.find({}, function (err, posts) {
if (err) {
req.flash('error', 'An unknown error has occurred.');
res.redirect('back');
} else {
homePosts.newest = posts;
}
}).limit(4).sort( { date : -1 } );