NodeJS Efficient Database Date timeout event

I have a huge database table which contains all posted threads. There is also a column DATE and a column blocked. Each thread should get blocked after 1 week automatically. The problem is I cannot setup a timer on each thread, since my server might restart sometimes. So I need to design the solution different. I also thought about doing frequently a whole database check whereas I keep the last blocked index seperate saved, so I continue from there to check. But maybe there are even more precise and efficient check methods? What would be good to do here ?

1 answer

  • answered 2020-05-22 12:41 Ifaruki

    Maybe you can setup an cron job to check every hour your database.

    0 * * * * /usr/local/bin/node /path/to/nodejs/script.js

    This means: This script gets executed every hour frequently.

    With every hour i mean: 1:00, 2:00, 3:00, 4:00, ... and so on.

    In script.js you can check your database