paint-brush
How to Erase Expired Docs Automatically with MongoDB (TTL index)by@lironer
22,645 reads
22,645 reads

How to Erase Expired Docs Automatically with MongoDB (TTL index)

by liron2mOctober 28th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow
EN

Too Long; Didn't Read

How to Erase Expired Docs Automatically with MongoDB (TTL index) I needed to delete some documents that I saved in MongoDB after some time. My wife told me that MongoDB already has that mechanism built-in. A background thread reads the values in the index and removes expired documents from the collection (usually every minute) The indexed field must be BSON date type or an array of BSON dates. If a document does not contain the indexed field, the document will not expire.

Company Mentioned

Mention Thumbnail
featured image - How to Erase Expired Docs Automatically with MongoDB (TTL index)
liron HackerNoon profile picture
liron

liron

@lironer

L O A D I N G
. . . comments & more!

About Author

liron HackerNoon profile picture
liron@lironer

TOPICS

Languages

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite