A TTL index automatically deletes documents after a specified time based on a date field. Use it for expiring data like sessions, OTPs, or temporary logs to avoid manual cleanup.
db.sessions.createIndex({ expiresAt: 1 }, { expireAfterSeconds: 0 })