Complete the code to create a TTL index on the 'createdAt' field that expires documents after 3600 seconds.
db.collection.createIndex({ createdAt: 1 }, { expireAfterSeconds: [1] })The expireAfterSeconds option sets the time in seconds after which documents expire. Here, 3600 seconds means documents expire after one hour.
Complete the code to create a TTL index on the 'lastModified' field that expires documents after 86400 seconds (1 day).
db.collection.createIndex({ [1]: 1 }, { expireAfterSeconds: 86400 })The TTL index must be created on the field that stores the date to expire documents. Here, it's lastModified.
Fix the error in the TTL index creation code by filling the blank with the correct option.
db.collection.createIndex({ expireAt: 1 }, { [1]: 3600 })The correct option name for TTL expiration time is expireAfterSeconds. Other options are invalid and cause errors.
Fill both blanks to create a TTL index on 'timestamp' field that expires documents after 7200 seconds (2 hours).
db.collection.createIndex({ [1]: [2] }, { expireAfterSeconds: 7200 })The TTL index must be created on the date field with ascending order (1). Negative or zero values are invalid for index direction.
Fill all three blanks to create a TTL index on 'expireAt' field with ascending order and expiration after 1800 seconds (30 minutes).
db.collection.createIndex({ [1]: [2] }, { [3]: 1800 })The TTL index is created on the 'expireAt' field with ascending order (1) and the option 'expireAfterSeconds' sets the expiration time.