When to drop a collection
Dropping a collection permanently removes its documents and indexes. Use it for discarded features, failed experiments, or rebuilding a collection with a new schema. Prefer deleteMany({}) only when you want to keep indexes/collection metadata.
Step-by-step with mongosh
- Connect:
mongosh "your-connection-uri" - Select DB:
use my_app_db - List collections:
show collections - Inspect a sample:
db.orders.findOne() - Drop:
db.orders.drop() - Confirm it returns
trueand no longer appears inshow collections.
Safety checklist before production drops
- Take a backup or snapshot (mongodump / Atlas backup).
- Confirm environment (dev vs prod URI).
- Stop writers that target the collection.
- Communicate with teammates if the collection is shared.
// Explicit drop
db.getCollection("orders").drop()
// Alternative: wipe documents but keep collection + indexes
db.orders.deleteMany({})
Permissions
Your database user needs privileges to drop collections. In Atlas, restricted users may fail — use a role that includes drop privileges for maintenance windows only.
Recovery notes
After a drop, recovery depends on backups. There is no undo button in mongosh. If you might need the data, archive to another collection or database first: db.orders.aggregate([{ $out: "orders_archive" }]).



