My update statement works for your sample document as included in the question description, but you'll have to modify to suit your current data.
Positional operator can match only one nested array item. From documentation at mongodb.org: As answered by Andrew Orsich, this is not possible for the moment, at least not as you wish.
I prefer to do this on the Mongo DB side, otherwise I have to load the document in client-side (Python) and construct the updated document and replace it with the existing one in Mongo DB.
UPDATE This is what I have tried and works fine IF THE Object Exists : For question #1, let's break it into two parts.
Current solution can be only load document, update as you wish and save back or multiple atomic update for each nested array id.
The default value is false, which does not insert a new document when no match is found." For multi, If set to true, updates multiple documents that meet the query criteria. @Martijn Scheffer, I don't see a way to do this as a single query anywhere in this thread.The $elem Match version does partial matching even if you have more than one field in the same element to match making it the superior method to do these things.I know it's an old answer, but I am having trouble really understanding the difference between queries made with $elem Match and their "normal" equivalent (like above).Something like: Note that this will only increment the first matched subdocument in any array (so if you have another document in the array with "item_name" equal to "my_item_two", it won't get incremented). To increment the total and the price of item_three in any document that contains "my_item_three," you can use the $inc operator on multiple fields at the same time. The answer for Question#2 is perfect and works fine :) But for Question#1, the problem is you should search for the document by "user_id", and not by "items.item_name". I felt like I was making this direction apparent from the links in my answer, but I kept getting resistance saying its not what he was looking for.In this case I can not use the Positional Operator, as I haven't specified the array in the search query. Guess the OP just needed to see examples on how to do multiple $inc.
What do you mean by "The $elem Match version does partial matching even if you have more than one field in the same element to match" ?