0
爲什麼在第二個查詢中導致該字段未定義?代碼如下:在查詢中訪問查詢中的MongoDB值
Survey.findById(req.params.id, function(err, survey) {
for (var i=0; i<=survey.businesses.length-1; i++) {
console.log(survey.businesses[i].votes); // This returns the expected value
UserSurvey.find({ surveyId: req.params.id, selections: survey.businesses[i].id }, function(err, usurvey) {
console.log(survey.businesses[i].votes); // businesses[i] is undefined
});
}
});
優秀 - 理智和完美。非常感謝。很多要學習! – 2014-10-31 20:10:11