let items = [
{
name: "Choco",
id: "12344",
qty: 24,
status: "open"
},
{
name: "Mils",
id: "12346",
qty: 5,
status: "open"
},
{
name: "boom",
id: "12345",
qty: 10,
status: "open"
}
];
Given the array above, is it possible to update the document without calling a forEach on each of them.
For instance what i am currently doing is this
_.each(items, function( item ) {
Orders.update({_id: doc.orderId, "items.id": item.id},
{
"$set": {
'items.$.status': item.status,
'items.$.qty': item.qty,
}
})
})
is it possible to just update the entire array at once without create a new mongo db transaction