2

I want my vow to have access to outerDocs and innerDocs from my topics but it doesn't.

'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);
    }
  }

What am I doing wrong?

4

1 回答 1

1

你不能像这样为回调设置参数,find 函数会自己做。改为这样做:

topic: function(outerDocs) {
  var self = this;
  anotherModel.find({}, function(err, docs) {
    self.callback(err, docs, outerDocs);
  });
},
于 2011-09-27T02:43:58.510 回答