Reputation: 452
I didn't found a question similar to mine and i'm not sure it's possible. I have several documents, each document is a person, for example :
{
"name" = "Paul",
"score" = 105
}
{
"name" = "John",
"score" = 98
}
Before the update i have a dict (in python) with the name and the new score {"Paul": 107, "John": 92}
. How do i update the score in all the documents from the dict in one request ?
Upvotes: 1
Views: 114
Reputation: 3185
You can not update multiple documents with different conditions in a single query. You can refer MongoDB update doc. MongoDB introduced a new parameter as multi but it has a different meaning. update query with param { multi: true }
will update multiple documents only which will match the same condition which we set in query part.
Optionally you can update multiple documents with loop through your query. This feature is still missing in MongoDB so we are also doing such thing in the same way.
Upvotes: 1