pengjunling 发表于 2018-10-26 13:14:44

【MongoDB学习笔记9】深入MongoDB的更新(update)操作:修改器$inc

> db.post.findOne({"id":0})  
{
  
      "_id" : ObjectId("54a530c3ff0df3732bac167f"),
  
      "id" : 0,
  
      "name" : "joe",
  
      "age" : 65,
  
      "comments" : {
  
                "1" : 4,
  
                "2" : 2,
  
                "3" : 3
  
      }
  
}
  
> db.post.update({"id":0}, {$inc:{"age":6}})
  
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })


页: [1]
查看完整版本: 【MongoDB学习笔记9】深入MongoDB的更新(update)操作:修改器$inc