0
我不能合併結果的每個發現這個代碼功能:遞歸查找函數調用然後合併結果
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));
沒有錯誤...但響應是一個空數組:(
請幫助...我如何合併結果?
謝謝你verry musch ...我是一個php開發人員...不知道異步:D –