【发布时间】:2013-06-27 02:38:28
【问题描述】:
我无法在这段代码中合并每个 FIND 函数的结果:
this.result = [];
_products.find().exec(function (err,products) {
this.products = products;
var productsCollection = [];
for(i=0;i<products.length;i++) {
_prices.find({uname:products[i].uname},function(err,prices){
var resultItem = {product:products[i],prices:prices}
this.result.push(resultItem)
}.bind(this))
}
res.json(200, this.result);
}.bind(this) );
没有错误...但是响应是一个空数组:(
请帮助...我如何合并结果?
【问题讨论】:
标签: javascript node.js mongodb mongoose