Recall & Review
beginner
What does the
drop() method do in MongoDB?The
drop() method removes the entire collection and all its data from the database permanently.Click to reveal answer
beginner
What is the purpose of
deleteMany() in MongoDB?deleteMany() deletes multiple documents inside a collection based on a filter but keeps the collection itself.Click to reveal answer
intermediate
Which operation is faster for removing all data:
drop() or deleteMany({})?drop() is faster because it removes the whole collection at once, while deleteMany({}) deletes documents individually.Click to reveal answer
intermediate
After using
drop(), what happens if you try to insert a document into the dropped collection?MongoDB will recreate the collection automatically when you insert a new document after dropping it.
Click to reveal answer
beginner
Can
deleteMany() be used to delete all documents in a collection?Yes, by passing an empty filter
{}, deleteMany() deletes all documents but keeps the collection.Click to reveal answer
What does
db.collection.drop() do?✗ Incorrect
drop() removes the whole collection and all its documents.Which method deletes documents but keeps the collection?
✗ Incorrect
deleteMany() deletes documents matching a filter but does not remove the collection.How do you delete all documents in a collection without dropping it?
✗ Incorrect
Passing an empty filter
{} to deleteMany() deletes all documents but keeps the collection.What happens if you insert a document after dropping a collection?
✗ Incorrect
MongoDB automatically recreates the collection when a new document is inserted after dropping.
Which is generally faster to remove all data from a collection?
✗ Incorrect
drop() is faster because it removes the entire collection at once.Explain the difference between
drop() and deleteMany() in MongoDB.Think about what happens to the collection itself in each case.
You got /4 concepts.
When would you choose
deleteMany({}) over drop()?Consider cases where collection metadata matters.
You got /4 concepts.