Updating nested array of objects

Helllo @Philip_Enaohwo,

Welcome to the community! :wave:

I notice you haven’t had a response to this topic yet - were you able to find a solution?
If not, then you can try below.

db.collection.updateOne(
    {"variants.items._id" :  "62be0271d373b2f2fc1826a8"},
    {$set: {
        'variants.$[].items.$[xxx].quantity': 999
    }},
    {arrayFilters: [
        {"xxx._id": '62be0271d373b2f2fc1826a8'}
    ]}
)

Your particular use case includes Array within an Array, below is the explanation of the query.

Let me know if you have any more questions. Happy to help! :slight_smile:

Regards,
Tarun

6 Likes