开发者

Vows with Async nested topics - scope problem

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) {开发者_Python百科
      console.log(err, innerDocs, outerDocs);
      return assert.equal(1, 1);
    }
  }

What am I doing wrong?


You can't set arguments to the callback like that, the find function will do that itself. Do this instead:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜