I've a document called cart, inside on a user document where I want to update the quantity value if the item is already present.
document:
{
"_id": {
"$oid": "614b72a9a6c2dd5aa95ee03e"
},
"name": "Mainak",
"email": "mainakdas104@gmail.com",
"cart": {
"items": [
{
"productId": {
"$oid": "614b771a6d33c02b74c669b7"
},
"quantity": 1
}
]
}
}
How do I iterate over the array, find and update the value of quantity ?
I'm using mongo-db npm driver.