I have the following document
{store : {
id : 'STORE1',
name : 'Electronics Store',
locations : [
{
id : 'LOC1',
quantity : 4
},
{
id : 'LOC2',
quantity : 10
},
{
id : 'LOC3',
quantity : 5
}
]
}
}
I want to update the quantity
of multiple elements of the locations
array based on their id
field using $inc
.
For example I want to update id : 'LOC1'
with +5 to the quantity
field and id : LOC3
with +2 to its quantity
field.
Is it possible to do this with one query in mongodb instead of using multiple queries for each location.