Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to schedule/queue a task based on saved mongodb document data [NodeJS]

I want to have a function in my server which a user can create a 'jobScan' from an API route for example '/create-scan-job which basically on the creation of a scanJob it will be saved in the mongodb database with a 'scanDueDate' which will be used to queue a task that will change the status of the scan to 'completed' on the dueDate that was inputted by the user.

How can I build something like this? I have no problem in saving the data in the database but how do I 'queue' it to fire on the dueDate that was given as input?

like image 712
Michael Parkadze Avatar asked Sep 15 '25 01:09

Michael Parkadze


1 Answers

You can use agenda or bull packages.

  1. Agenda saves jobs in MongoDB database
  2. Bull saves jobs in Redis.

Both support cron jobs.

like image 105
Dheemanth Bhat Avatar answered Sep 16 '25 15:09

Dheemanth Bhat