更新操作
1.db.col.update({name:"juyi"}, {$set:{country:"china"}}, {multi:true});
2.db.col.update({},{$set:{"favorites.fruit":["apple","banana"]}},{multi:true})
3.db.col.update({name:"tom"},{$push:{"favorites.fruit":{$each:["grapes","watermelon"],$slice:-3}}})
查询操作
1.db.col.find({comments:{$exists:false}})
2.db.col.find({"favorites.movies":{$all:["肖生克的救赎","头号玩家"]}})
3.db.col.find({$and:[{name: {$regex: "bu"}},{$or:[{age:{$lt:20}},{age:{$gt:24}}]}]});
4.db.col.find({comments:{$elemMatch:{userId:"101",content:"评论1"}}})
5.db.col.find({name:"xiaobu"},{comments:{$slice:[0,3]}})
6.db.col.find({name:"xiaobu"},{comments:{$slice:[1,1]},$elemMatch:""})
7.db.col.find({"comments.userId":{$in:["001","101"]}})