db # list all databases, if not exist, it will be created when you insert data
use <database> # switch to a database
show collections # list all collections in a database
db.dropDatabase() # drop current database
db.createCollection("collectionName") # create a collection
db.<collections>.findOne(<{}>) # return the first document in a collection if the parameter not specified
db.<collections>.find() # list all documents in a collection
db.customer.find({gender: "male"},{_id: false, gender: 0, age: false}).pretty()
db.<collections>.insert({name: "John", age: 30}) # it can be insert one or multiple documents
db.<collections>.insertOne({name: "John", age: 30}) # insert a document `_id` will be generated automatically
db.<collections>.insertMany([{name: "John", age: 30}, {name: "Jane", age: 25}])
db.<collections>.deleteOne({name: "John"}) # delete a document
db.<collections>.deleteMany({name: "John"}) # delete multiple documents
db.<collections>.updateOne({name: "John"}, {$set: {age: 31}}) # update a document
db.<collections>.updateMany({name: "John"}, {$set: {age: 31}}) # update multiple documents
db.<collections>.find().toArray() # convert the cursor to an array
db.<collections>.find().forEach(function(doc) {print("Name: " + doc.name)}) # iterate over the cursor
db.<collections>.find().pretty() # pretty print the documents
typeof db.<collections>.find()
db.stats() # get the statistics of the database