求指导bluebird的写法
router.post('/post', function(req,res){
var currentUser = req.session.user;
var post = new Post(currentUser.name, req.body.post);
post.save(function(err){
if(err){
req.flash('error', err);
return res.redirect('/');
}
req.flash('success', 'post success.');
res.redirect('/u/'+ currentUser.name);
});
});
用 bluebird 该怎么写呢, bluebird的api看的有点糊涂 new Promise(function(function resolve, function reject) resolver) -> Promise
6 回复
var Order = mongoose.model('Order', orderSchema);
var Promise = require("bluebird");
Promise.promisifyAll(Order);
Promise.promisifyAll(Order.prototype);
然后
post.saveAsync(xxxx).then(xxxx).cache(err)