Usefull MongoDB Commands:

  1.  use DATABASE_NAME – To select the DB which you are going to use.
  2. db – Will show the current selected DB
  3. show dbs – It will show list of Database which is available in MongoDB
  4. db.dropDatabase() – Go to DB which is have to drop & execute this command.
  5. db.createCollection(“testCollection”) – To Create collection in MongoDB . Here collection will create with the name of “testCollection”
  6. show collections – Will list of all the collection from the selected DB.
  7. db.<COLLECTION_NAME>.drop() – To drop the Specific collection from the DB which we selected from MongoDB.
  8. db.<COLLECTION_NAME>.insert(document) – To insert the document into Collection.Ex: >db.<testCollection>.insert({ _id: ObjectId(QTWRWTWT),title: ‘Testing’})
  9. 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
  10. Similarly MongoDB is having option to select , insert , update , delete, save, find document.

 

CORNER OF BLOG:

“SAVE WATER”