5 Basic MongoDb commands

MongoDB is one of the most popular open-source, No-SQL, document based databases.

MongoDB commands follows JSON like structure. The 5 most widely used Mongodb commands are:

Connect to mongoDB shell

Type the above command in terminal to connect to mongoDB shell

mongo

List databases

The above command will list the databases present in MongoDB

show dbs

Create a new collection 

createCollection command will  Create a collection name "demo"

db.createCollection('demo')

Insert Record into the mongo collection

Insert command will insert a document into the MongoDB demo collection.

db.demo.insert({'name': 'cloud'})

List all documents in a collection

The command will list all documents present in the Mongodb demo collection.

db.demo.find()