Data type: NULL bool Numeric string date regular array Document object ID Binary code show DBS; // Show tables; Db.stats (); Db.col.stats (); db.col.stats (); / / information such as the size of the check table To the operation of the collection: db. Coll. Insert ({” name “:” ABC “}) the coll. Insert ([{” name “:” ABC “}, {” name “:” def “}, {” name “: “lll”}, {“name” : “kkk”}]) db.coll.remove({}) db.coll.remove({“name” : “def”}) db.coll.update({“_id” : 1}, {“name” : “456”}) db. Coll. Update ({” _id “: 1}, {” $inc” : {” count “: 1}}) / / every increase 1 db. Coll. Update ({” _id” : 1}, {” $set “: {” NNNN” : “LLLLL”}}) / / modify or new db, coll. Update ({” name “:” ABC “}, {” $set “: {” sex” : 0}}, true, true) / / not just create multiple document operation the coll. Save ({” _id “: 1,” name “:” ABC “, “sex” : 3}) / / no is inserted, modified (according to the _id) db. RunCommand ({” findAndModify “:” coll “, “query” : {” name “:” ABC “}, “sort” : {” sex “: 1}, “update” : {” $inc “: {” count” : 3}}, “new” : true, “fields” : {” sex “: 1,” count “: 1}}) array: / / db increase array. Coll. Update ({” name “:” LHH “}, {” $push “: {” MMMM” : {” $each “: [{” count” : 1}, {2} “count” :, {” count “: 3}, {“count” : 8}, {“count” : 4}, {“count” : 2}, {“count” : 9}, {“count” : 13}], “$slice” : -5, “$sort” : {“count” : – 1}}}}) db. Coll. Update ({” _id “: 1}, {” $pop” : {” contents “: {” key” : 1}}}) / / from the front after delete the coll. Update ({” _id “: 1}, {$” pull “: {” contents” : 1}}) / / delete element set db. Coll. Update ({” contents. Con “:” 77885 “}, {” $set “: {” contents. $. Con” : “Hello worlddddd”}}) / / modify an element of the array query: the coll. Find ({}, {” name “: 1,” age “: 1,” _id “: 0}) the coll. Find ({” age” : {“$gte” : 16, “$lte” : 30}}) date = new Date(“2017-01-02”) date = new Date() db.coll.find({“date” : {“$lt” : Date}}) db. Coll. Find ({” name “: {” $ne” : “GGG”}}) / / is not equal to the coll. Find ({” age “: {” $” in: [18, 19, 20]}}) db.coll.find({“$or” : [{“name” : “hhh”}, {“age” : 21}]}) db.coll.find({“age” : {“$mod” : [5, 1)}}) / / query the age data modulus for 1 to 5 db. The coll. Find ({” age “: {” $not” : {” $mod “: [5, 1)}}}) / / query the age data modulus is not 1 to 5 db. The coll. Find ({” name “: {” $eq” : “HHH”}}) / / equal to the coll. Find ({” $” and “: [{” age” : {” $gt: 18}}, {” name “: {” $ne” : “JJJ”}}]}) the coll. Find ({” name “: {” $eq:” null, “$exists” : true}}) regular: Db. Coll. Find ({” name “: / HH? / I}) / / I is for case-insensitive db. Coll. Find ({” name” : / HH? /}) the coll. Find ({” name “: / HH /}) array: Db. Coll. Find ({” cont “:” name “}) the coll. Find ({” cont “: [” name”, “auth”, “body”]}) with $for single and array in matching: db.coll.find({“cont” : {“$in” : [“name”]}}) db.coll.find({“cont” : {“$in” : [” name “, “auth”, “body”]}}) the coll. Find ({” cont “: {” $” in: [” name”, “auth”]}}) so the query arrays of multiple matches with $all: db.coll.find({“cont” : {“$all” : [“name”, “auth”]}}) db.coll.find({“cont” : {“$size” : 3}}) / / according to the length of the array query db. The coll. Find ({” name “:” HHH “}, {” cont “: {” $slice” : 2}}) / / return the first two array elements the coll. Find ({” name “: “HHH”}, {” cont “: {” $slice” : – 2}}) / / return after an array of two elements the coll. Find ({” name “:” HHH “}, {” cont “: {” $slice” : [1, 2]}}) // Return the first two elements db.col.find ({“cont.2” : “auth”}) // The third element matches db.col.find ({“cont.name” : “Hello”}, {” cont. $” : 1}) / / query any db. A matching array coll. Find ({” num “: {” $elemMatch” : {” $gt: “18,” $lt “: 50}}}) / / query has meet the conditional elements of an array, if have the whole array will return the coll. Find ({” num “: {” $gt:” ten, “$lt: 20}}), min ({10}” num “:). Max ({” num” : Db.coll. find({“art.auth” : “Joe “, “art.num” : {“$gt” : 20, “$lt” : {“$gt” : 20, “$lt” : {“$gt” : 20, “$lt” : 51}}) db.coll.find({“cont” : {“$elemMatch” : {“art.num” : 39, “art.auth” : “kiki”}}}) $where : Db.coll. find({“$WHERE “: function() {for(var other in this) {if(var other in this)! = this && this[current] == this[other]){}return true; }} return false; }}) db.coll.find({“$where” : function() { if(this.name == “hhh”) return true; return false; }}) script execution on the server to prevent injection use scope databases use cursor to return to the execution of the find as a result, the cursor is equal to the pointer in C language, call the find, shell is not immediately query the database, but only when waiting for the results really start asking for sending the query, so before the query can give query additional options. cursor = db.coll.find() while(cursor.hasNext()) { print(cursor.next()); } cursor.forEach(function(x) { print(x.name) }); Db.col.find ().limit(3).skip(1).sort({“name” : 1}) Db.col.find ()._addSpecial(“$maxscan”, 3) $min: $Max: Db.col.find ()._addSpecial(“$showDiskLoc”,true) // Display the location of the result on the disk. Because the cursor moves to the right from the beginning, but the document moves as it grows, the cursor may move the same cursor more than once. The cursor lifecycle: on the server side, the cursor consumes memory and other resources. 2. The client sends a message requesting termination. 3. Db.runcommand () : Example: db.runCommand({“getLastError” : AdminCommand () : adminCommand db. AdminCommand ({“shutdown” : 1}) db. RunCommand ({“drop” : “test”}) db. AdminCommand () : adminCommand db. Db.$cmd.findOne({“drop” : “test”}) // Do some special processing by querying $CMD set \