时间:2021-07-01 10:21:17 帮助过:2人阅读
1 db.games.insert({game:"pinball",user:"joe"}) 2 db.games.find() 3 db.games.update({"game":"pinball","user":"joe"},{"$inc":{"score":50}}) 4 db.games.update({"game":"pinball","user":"joe"},{"$inc":{"score":10000}})
运行结果分别为
1 /* 1 */ 2 { 3 "_id" : ObjectId("575a37da8fd26400d774e00a"), 4 "game" : "pinball", 5 "user" : "joe", 6 "score" : 10150.0 7 }
db.games.update({"game":"pinball","user":"joe"},{"$inc":{"score":50}})
1 /* 1 */ 2 { 3 "_id" : ObjectId("575a37da8fd26400d774e00a"), 4 "game" : "pinball", 5 "user" : "joe", 6 "score" : 10200.0 7 }
MongoDB修改器的使用2
标签: