Saturday, 18 January 2020

Architectural Question for Nodejs Server/Mongodb

I'm creating a client/server application where the client can upload a document to a collection on mongodb.I want to make this document expire within, say 5 days. I am aware that mongodb has an option to do that within its collections. But I also want to "trigger" an action when the expiration has 1 day left (such as send a notification to the client informing them of expiration within 1 day) and to actually perform other actions, such as a removing a document from another collection when the former document has expired.​I'm unsure exactly how to proceed here, especially because I don't think mongodb has any triggers. Maintaining a separate thread for each user to keep track of the expiration seems too costly and inefficient, same as having the client scan every minute to check for expiration/triggering on expiration.Recap – when document has 1 day left before expiration, send notification to client. When document actually does expire, perform functions A and B.Any advice?Thanks!

Submitted January 18, 2020 at 09:21PM by the_night_question

No comments:

Post a Comment