I currently have a chat bot setup to store records onto MongoDB. The object that's stored in Mongo looks like...
{ ..., expiration_time: 12451525, ... }
Where expiration_time
is a number represented in minutes.
My initial approach was use setInterval
on the web application to query the database to delete all records that matched the criteria of current time being greater or equal to expiration time. However, I feel like there would be a lot of additional queries to the database from the web application, when there are already other operations such as reading and writing data.
I read about storing functions onto Mongo, but I'm sure how to automate the process of invoking the function to self delete the records.
I would definitely love any feedback, approach, or guidelines for best practices.
Thanks in advance!