小白提问.
db.users.insert({"name": "demo"})
以上插入十遍.
db.users.update({"name": "demo"}, {$set: {"age": 24}})
这条案例来说应该十条记录全部匹配上,但是为什么仅仅匹配了第一条呢?
https://docs.mongodb.org/getting-started/shell/update/#update-multiple-documents
The foundation is not very solid, please read the manual more.
db.users.update({"name": "demo"}, {$set: {"age": 24}},{multi: true}) db.collection.update( <query>, <update>, { upsert: <boolean>, multi: <boolean>, writeConcern: <document> } )
db.users.update({},{},true,true) The contents in the curly brackets remain unchanged. The default is to update one item. Just add the two parameters true!
https://docs.mongodb.org/getting-started/shell/update/#update-multiple-documents
The foundation is not very solid, please read the manual more.
db.users.update({},{},true,true) The contents in the curly brackets remain unchanged. The default is to update one item. Just add the two parameters true!