mongo db delete code example

Example 1: drop mongo database

// First show what databases have you gotten 
show dbs
// then, use the database name that you want to drop
use YOUR_DATABASE_NAME
// now you can drop it
db.dropDatabase()
// show collections should be empty now
show collections

Example 2: drop mongodb database

db.dropDatabase()

Example 3: how to delete a document in mongodb

to delete a document
db.games.deleteOne({name:"Snake"})

Example 4: deletemany mongodb

try {
   db.orders.deleteMany( { "client" : "Crude Traders Inc." } );
} catch (e) {
   print (e);
}

Example 5: mongodb delete all documents

db.collection.delete_many( { } );

Example 6: mongo delete all documents

db.bios.remove( { } )