使用Async嵌套主题的誓言 – 范围问题

我希望我的誓言能够访问我的主题中的outerDocs和innerDocs,但事实并非如此。

'ASYNC TOPIC': { topic: function() { aModel.find({}, this.callback); }, 'NESTED ASYNC TOPIC': { topic: function(outerDocs) { anotherModel.find({}, this.callback(null, innerDocs, outerDocs)); }, 'SHOULD HAVE ACCESS TO BOTH SETS OF DOCS': function(err, innerDocs, outerDocs) { console.log(err, innerDocs, outerDocs); return assert.equal(1, 1); } } 

我究竟做错了什么?

你不能像这样设置callback参数,查找function会自己做。 做这个,而不是:

 topic: function(outerDocs) { var self = this; anotherModel.find({}, function(err, docs) { self.callback(err, docs, outerDocs); }); },