The MongoDB version when used is: 3.2
1. Export:
Mongoexport--host mongodb1.example.net--port 37017--username user--password pass--collection contacts--db Marketing --out Mdb1-examplenet.json
2. Import:
Mongoimport--host mongodb1.example.net--port 37017--username user--password pass--collection contacts--db Marketing --file/opt/backups/mdb1-examplenet.json
3, Multi-criteria search:
Db.collection.find ({lang: "zh", createtime:{$gte: New Date ("3/31/2015 6:52:46")}); {"Liju": {$ne: null}, "Liju.mediaid": {$ne: null}};
4. Query and Sort:
Db.collection.find (). Sort ({Age:-1})-1 is descending, 1 is the positive sequence Db.collection.find ({$query: {}, $orderby: {Age:-1}})
5, Batch update:
var bulk = Db.items.initializeUnorderedBulkOp (); Bulk.find ({Status: "D"}). Update ({$set: {status: "I", Points: "0"} }); Bulk.find ({item:null}). Update ({$set: {item: "TBD"}}); Bulk.execute ();
MongoDB Use Command Summary