I am working on a react native & MongoDB project that has posts which expire after 7 days from the time of creation. and then change the status to expired.
I am currently thinking of checking at the start of each day for posts that will expire soon then notify the user, but how would I actually change the status to expired at the exact moment it expires?
CodePudding user response:
Since your posts have the creationTime as attribute I would get the current time every one minute or so and then check if the creationTime 7 days is smaller than the current time and if so, remove the post. If you really need it at the EXACT time, you can get performance problems with a lot of posts as you would have to implement potentially multiple timers and they are really heavy.