drop()
noun
say it: “DROP” /ˈdrɑp/
A MongoDB method that deletes a whole collection, with all its documents and indexes.
What does drop() do?
drop() removes a whole collection: every document, its indexes and the collection itself. deleteMany({}) removes only the documents and leaves the empty collection, indexes and all.
db.practice_recipes.drop();
// true
db.getCollectionNames().includes("practice_recipes");
// false
In a sentence
- “There's no undo for drop(), so check the collection's name twice.”
- “At the end of the exercise, drop() cleared away the practice collection in one call.”
Level: Apprentice · More MongoDB terms at this level
Updated