> db.users.find({"favorites.artist": "Picasso"},
  ... {finished:0,points:0,badges:0}).pretty()
  //查询favorites.artist值为Pisanello的文档
  > db.users.find({"favorites.artist": "Pisanello"},
  ... {finished:0,points:0,badges:0}).pretty()
  {
  "_id" : 1,
  "name" : "sue",
  "age" : 19,   //Author : Leshami
  "type" : 3,   //Blog   : http://blog.csdn.net/leshami
  "status" : "P",
  "favorites" : {
  "artist" : "Pisanello",
  "food" : "pie"
  },
  "lastModified" : ISODate("2016-09-30T08:00:47.826Z")
  }
  {
  "_id" : 6,
  "name" : "abc",
  "age" : 43,
  "type" : 3,
  "status" : "A",
  "favorites" : {
  "food" : "pizza",
  "artist" : "Pisanello"
  },
  "lastModified" : ISODate("2016-09-30T08:00:47.826Z")
  }
  3、db.collection.update()
  //下面使用db.collection.update()方式更新
  > db.users.update(
  ...    { "favorites.artist": "Pisanello" },
  ...    {
  ...      $set: { "favorites.food": "pizza", type: 0,  },
  ...      $currentDate: { lastModified: true }
  ...    }
  ... )              //此更新结果,如下行,nMatched为一个文档,nModified为1个文档,即仅更新一个文档
  WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })  //等同于updateOne方法
  > db.users.update(
  ...    { "favorites.artist": "Pisanello" },
  ...    {
  ...      $set: { "favorites.food": "pizza", type: 0,  },
  ...      $currentDate: { lastModified: true }
  ...    },
  ...    { multi: true }         //使用参数multi,且值为true
  ... )                          //从返回的结果可知,更新文档数为2,即所有满足条件的文档都被更新
  WriteResult({ "nMatched" : 2, "nUpserted" : 0, "nModified" : 2 })  //等同于updateMany方法
  //验证更新之后的结果
  > db.users.find({"favorites.artist": "Pisanello"},
  ... {finished:0,points:0,badges:0}).pretty()
  {
  "_id" : 1,
  "name" : "sue",
  "age" : 19,
  "type" : 0,
  "status" : "P",
  "favorites" : {
  "artist" : "Pisanello",
  "food" : "pizza"
  },
  "lastModified" : ISODate("2016-09-30T09:31:10.524Z")
  }
  {
  "_id" : 6,
  "name" : "abc",
  "age" : 43,
  "type" : 0,
  "status" : "A",
  "favorites" : {
  "food" : "pizza",
  "artist" : "Pisanello"
  },
  "lastModified" : ISODate("2016-09-30T09:31:10.524Z")
  }
  4、db.collection.replaceOne()
  //替换前文档的内容(name:"abc")
  > db.users.find({name:"abc"},{finished:0,points:0,badges:0}).pretty()
  {
  "_id" : 6,          
  "name" : "abc",
  "age" : 43,
  "type" : 1,
  "status" : "A",
  "favorites" : {
  "food" : "pizza",
  "artist" : "Picasso"
  }
  }
  //下面使用db.collection.replaceOne()替换用户名为abc的文档,且替换了很多不同的键值
  > db.users.replaceOne(
  ...    { name: "abc" },
  ...    { name: "amy", age: 34, type: 2, status: "P", favorites: { "artist": "Dali", food: "donuts" } }
  ... )
  { "acknowledged" : true, "matchedCount" : 1, "modifiedCount" : 1 }  //这里提示有一个匹配,一个被更新
  //验证替换后的结果
  > db.users.find({name:"amy"},{finished:0,points:0,badges:0}).pretty()
  {
  "_id" : 6,
  "name" : "amy",
  "age" : 34,
  "type" : 2,
  "status" : "P",
  "favorites" : {
  "artist" : "Dali",
  "food" : "donuts"
  }
  }
  //使用db.collection.update方式可以实现相同的效果
  > db.users.update(
  ...    { name: "xyz" },
  ...    { name: "mee", age: 25, type: 1, status: "A", favorites: { "artist": "Matisse", food: "mango" } }
  ... )
  WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
  三、小结
  1、mongoDB文档更新有很多个不同的方法,传统的update,以及3.2版本之后的updateOne,updateMany
  2、mongoDB文档替换也有很多个不通的方法,传统的update,以及3.2版本之后的replaceOnye,replaceMany
  3、updateOne与updateMany是对update方法的扩展,update方法可以通过multi值为true或false来等同于updateMany以及updateOne
  4、replaceOne与replaceMany也是对update方法的扩展,update方法可以通过multi值为true或false来等同于replaceMany以及replaceOne