【发布时间】:2014-08-21 04:45:23
【问题描述】:
我有这个源代码:
UserSchema.post('save', function (next) {
doSomethingAsync(function(){
next()
});
});
myFunc = function(user){
Q.ninvoke(user, 'save').then(function(){
doThisAtTheEnd()
});
}
但是 then 在 "doSomethingAsync" 调用之前调用是回调。这怎么可能?! 完成所有保存内容后,我如何调用“then”?
非常感谢
编辑: 这两个函数在不同的文件中,没有办法也无意使用全局变量。
【问题讨论】:
标签: node.js mongoose promise q