Problem: I am not able to increment nested array document field as positional operator $ only points to parent array.
Here is my doc firm:
{
"_id" : ObjectId(...),
Whol : [ "name" : 'praveen',
credit_note : [{id : 123, amount : 20 },{id: 456 ,amount : 10},{..}]
]
}
I tried this but doesn't work:
db.firm.update({_id: ,'whol.id':,'whol.credit_note.id' : 123},
{$inc : {'whol.credit_note.$.amount': 100}}
)
Result expected
{
"_id" : ObjectId(...),
Whol : [ "name" : 'praveen',
credit_note : [{id : 123, amount : 120 },{id: 456 ,amount : 10},{..}]
]
}