ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)
Set your Publisher ID in src/config/ads.ts to display live ads.
MongoDB NoSQL Database Tutorial• 5 min read
Deleting Records & TTL Auto-Expiring Documents
Remove documents with deleteOne/deleteMany and configure TTL (Time-To-Live) indexes for auto-expiring user sessions.
Automatic Expiration with TTL Indexes
db.sessions.createIndex({ "createdAt": 1 }, { expireAfterSeconds: 3600 }) automatically deletes session documents 1 hour after creation.
ADVERTISEMENT
Google AdSense Slot (inContentBanner)
Set your Publisher ID in src/config/ads.ts to display live ads.
Test Yourself With Exercise
Which index option instructs MongoDB to automatically delete documents after a specified number of seconds?