How can i set an event in Mongodb
?
I will create an event that every 4 hours Calculate fields (SUM|COUNT) in the Collection And Save it. What is the best So
As of version 3.2 MongoDB has no buildin cronjob system (with the exception of the TTL index auto-delete jobs, but these won't help you to solve this problem).
That means you will have to use an external tool to start the mongo shell with your query as a parameter to it. There are countless tools available for this, some build into all common operating systems out-of-the box and some in form of 3rd party tools. There are far too many options to list them all and which one is the best depends on your IT infrastructure and what your system administrators prefer.
Try MongoDB Cron package. It's a simple API for scheduling tasks and running recurring jobs on MongoDB collections. Any collection can be converted into a job queue or crontab list.