- use DATABASE_NAME – To select the DB which you are going to use.
- db – Will show the current selected DB
- show dbs – It will show list of Database which is available in MongoDB
- db.dropDatabase() – Go to DB which is have to drop & execute this command.
- db.createCollection(“testCollection”) – To Create collection in MongoDB . Here collection will create with the name of “testCollection”
- show collections – Will list of all the collection from the selected DB.
- db.<COLLECTION_NAME>.drop() – To drop the Specific collection from the DB which we selected from MongoDB.
- db.<COLLECTION_NAME>.insert(document) – To insert the document into Collection.Ex: >db.<testCollection>.insert({ _id: ObjectId(QTWRWTWT),title: ‘Testing’})
- db.<COLLECTION_NAME>.find() – This command will return the all the document. With this command we will give the Where Clause. Like how we will use Where clause from Mysql.
Ex: db.<COLLECTION_NAME>.find({“likes”:{$gt:1000}}).pretty() //Greather than 1000 - Similarly MongoDB is having option to select , insert , update , delete, save, find document.