Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumMongoDBTTL indexesSingle-choice MCQ

You want a collection where each document can specify its OWN expiration time rather than sharing a single fixed lifetime. How do you configure the TTL index?

db.tokens.createIndex({ expireAt: 1 }, { expireAfterSeconds: 0 }) db.tokens.insertOne({ token: "x", expireAt: ISODate("2026-12-31T23:59:59Z") })