mongodb remove all from collection
db.collection.remove({})
delete in mongodb
//To delete all documents db.movies.deleteMany({}) //Delete All Documents that Match a Condition db.movies.deleteMany( { title: "Titanic" } ) //Delete Only One Document that Matches a Condition db.movies.deleteOne( { cast: "Brad Pitt" } )
Source: www.mongodb.com
mongodb delete all documents
db.collection.delete_many( { } );
how to delete a document in mongodb
to delete a document db.games.deleteOne({name:"Snake"})
MongoDb delete
1 db.coll.remove({name: "Max"}) 2 db.coll.remove({name: "Max"}, {justOne: true}) 3 db.coll.remove({}) // WARNING! Deletes all the docs but not the collection itself and its index definitions 4 db.coll.remove({name: "Max"}, {"writeConcern": {"w": "majority", "wtimeout": 5000}}) 5 db.coll.findOneAndDelete({"name": "Max"})
Source: www.mongodb.com
mongo delete all documents
db.bios.remove( { } )
Source: docs.mongodb.com