How to update value inside object of objects

Viewed 45

I have this document in mongodb. enter image description here I want to update the PENDING status to ORDER PLACED. How do I do that? I am try with this but not working. First I am finding the document by ordered then update it.

for (let item in orderedProducts) {
await db.collection("orders").updateOne(
          { order_id: parseInt(myrequest.orderId) },
          {
            $set: {
              `ordered_products.${item}.orderStatus`: "Order Placed"
            }
          })}
0 Answers
Related