I have a range of Product items in my inventory and when a client places an Order, they submit an array of objects. Each object in the array includes the _id product (objectId) and the quantity they purchased.
[
{producId: "dshsdsdh72382377923",
quantity: 20
},
{producId: "dsh673sdh72382377923",
quantity: 10
},
{producId: "hjddjkdjkdj676372373",
quantity: 5
},
]
I would like to query the Product Collection and update the numberInStock of each product by subtracting the quantity bought by the client! Is there a way to achieve this?