mongodb drop collection code example

Example 1: mongodb drop db

db.dropDatabase()

Example 2: drop a collection in mongodb

db.mycollection.drop()

Example 3: how to drop db in mongo shell

use DB_NAME       // go to the db you want to delete

db.dropDatabase()

show dbs
// droppped db will not be shown

Example 4: delete collection mongodb

db.collection.drop()

Example 5: delete an item from db collection mongodb

db.collection.remove(
   <query>,
   {
     justOne: <boolean>,
     writeConcern: <document>
   }
)

Example 6: mango to delete a collection

db.CollectionName.drop()