Last Updated: November 21, 2025
Focus Areas
| Focus |
|---|
Create TTL indexes
|
Archive before deletion
|
Commands & Queries
db.logs.createIndex({ createdAt: 1 }, { expireAfterSeconds: 2592000 })
Set TTL
mongoexport --collection logs
Export data
db.collection.remove({})
Purge
Summary
TTL indexes automate cleanup for temporary collections.
💡 Pro Tip:
Include `expireAfterSeconds` and back up before TTL deletes.