A
A
ArthurSupertramp2015-01-01 21:32:30
Node.js
ArthurSupertramp, 2015-01-01 21:32:30

How to write a Node.js script that cleans up the database from time to time?

In general, there is a base that needs to be cleaned from time to time. That is, delete old records, accompanying this with the deletion of files, the paths to which are stored in this database. I want it to work offline, once every 1 hour approximately. How it is better to implement it?
Stack

  • nodejs
  • Express
  • mongodb
  • mongoose

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Shikanov, 2015-01-02
@ArthurSupertramp

It is better to add a script to the cron so that he does not need to eat memory all the time.

S
Safort, 2015-01-01
@Safort

setInterval(function() {
//database cleanup code
}, 1000*60*60);
As you can see, it's pretty simple)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question