function ParseOrderSchema(CartItems , callback)
{
var lookup = 0;
var subOrderList = new Array();
for(var i=0;i<CartItems.length;i++)
{
Meal.findOne({ _id: CartItems[i].id }).lean().exec(function (err, meal) {
console.log(CartItems[i]);
//meal.mealQTY = CartItems[i].qty;
var s = new subOrder({ meals: meal, deliveryDate: getMomentDate(0) });
subOrderList.push(s);
if (++lookup == CartItems.length) callback(subOrderList);
});
}
}
At CartItem[i].id it works fine and is able to work fine. But it fails at this line meal.mealQTY = CartItems[i].qty;
It can't recognize CartItems[i] inside the findOne() method.
Mealschema?