Reputation: 545
The following is the basic structure of my schema :
Whenever I update the value of one of the "powerups"(first 4 items), I set the powerupTimer to the time one of these fields was changed (only 1 powerup can be active at a time). I want the all the values to be false after 1 hour, I am not able to figure out how I can reset them 1 hour after the time was recorded.
I am thinking of going with this approach but am not too sure about its impact on performance and limitations of the m0 free cluster:
I will set the field "powerupTimer" to be 60, and decrease it by 1 every minute (making a cron job) and when it is equal to zero, I will set the top four fields to be false.
Obviously, there must be a better way to implement a timer function like this in mongodb, please help me in implementing it.
Upvotes: 0
Views: 497
Reputation: 2474
You can keep your idea of a cron job that executes every minute.
But you can just perform an update
request witch set the fields to false
when powerupTimer
is lower than the current hour minus one hour.
Upvotes: 1