How to reset the counter every day?

Needs to be reset each new day count and do not understand where to dig and how to implement this idea, wash, but I think maybe there's a more interesting way.

{
 _id: $id,
 count: 100
}


Every day the count field to set to 0.

Comes to mind only by crontab once a day all records Jahan counter.
I wonder if there is any more elegant option, for example embedded in most of Monge? For example, if you create an additional field with the time of the last reset count field and update the change document check box, and reset it? Maybe there are some built-in thing with the refresh interval field, I'm not aware of?

Or was it just hardcore crontab? =)
August 23rd 19 at 10:43
1 answer
August 23rd 19 at 10:45
Solution
Or was it just hardcore crontab? =)
It's not hardcore, but one of the practices (one approach).

For example, if you create an additional field with the time of the last reset count field and update the change document check box, and reset it?
Can have an additional field with the date, and if the counter != 0 and date == today, and the update time >= "it is time", reset the counter to 0 and increase the date by 1 day. But in my opinion, every time to pull a document that would check the date and all so perverted as something not serious, especially if such inspections in a day is not 10 or 20... (if a little, it doesn't matter)

PS MySQL is planirovat your at the DB level. In Monge I do not remember this...
Well hardcore in terms of crontab for me a permanent solution to some problems, really helps and so already used to it =)

I was wondering if there's a planner some might still do eventually =) - korey.Lindgr commented on August 23rd 19 at 10:48
: maybe there is, I'm with Mongo though familiar, but not expert level on this, I can only assume that more likely it's not there...

*we have CRON e too much tied, hell of a thing! :D - Jocelyn.Jakubowski43 commented on August 23rd 19 at 10:51

Find more questions by tags MongoDBMongoose