I’m having problems updating a record. My document structure is something like this:
"_id" : "1141825507009",
"person" : [
{
"amount" : 25,
"id" : "1141825507009"
}
]
I want to increment person.amount by 3 where person.id is 1141825507009. That easy.
What about:
Increment person.amount by 3 if person.id exist.
Add to person list with amount 3 and id 239something845 if person.id does not exist in list.
I think what you want is https://jira.mongodb.org/browse/SERVER-340. You might want to watch/vote for.
If you don’t need to do it atomically, you could do something like: