const updateStatus = asyncHandler(async (req, res) => { console.log("k"); const { customer, stageFiveId, availableLoansId, status } = req.body; console.log(req.body); const customerData = await Customer.updateMany( { _id: customer, }, // db.coll.update({}, {$set: {“a.$[i].c.$[j].d”: 2}}, {arrayFilters: [{“i.b”: 0}, {“j.d”: 0}]}) { $set: { "stage5.$[i].availableLoans.$[j].status": status }, }, { arrayFilters: [{ "i._id": stageFiveId }, { "j._id": availableLoansId }] } ); console.log(customerData); if (customerData) return res.status(200).json({ success: true, message: "Status updated sucessfully!", }); else return res.status(400).json({ success: false, message: "Could not able to update Status!", }); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter