我希望我的誓言可以从我的主题访问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);
}
}
我做错了什么?
答案 0 :(得分:1)
你不能像这样设置回调参数,find函数会自己做。这样做:
topic: function(outerDocs) {
var self = this;
anotherModel.find({}, function(err, docs) {
self.callback(err, docs, outerDocs);
});
},