way to update multiple documents with different values

后端 未结 4 1106
再見小時候
再見小時候 2021-01-17 08:41

I have the following documents:

[{
  \"_id\":1,
  \"name\":\"john\",
  \"position\":1
},
 {\"_id\":2,
  \"name\":\"bob\",
  \"position\":2
},
 {\"_id\":3,
           


        
4条回答
  •  隐瞒了意图╮
    2021-01-17 09:16

    You can not update two documents at once with a MongoDB query. You will always have to do that in two queries. You can of course set a value of a field to the same value, or increment with the same number, but you can not do two distinct updates in MongoDB with the same query.

提交回复
热议问题