I have an array of _ids which contains MongoDB's ObjectIds. Now I want to update all the documents of those _ids at once. I have tried this way, but it is updating only the first element of the array:
Product.update({
_id: { "$in": req.body.idArray }
}, req.body.payload).then((product) => {
console.log('Array of ids updated', product);
res.json({ status: true, product: product })
});
How to update all the _ids present in the array? Also, would there be a significant lag (which apparently I faced) if I update them each?