so-punctual
v0.0.3
Published
Lightweight MongoDB job scheduler
Downloads
2
Readme
so-punctual
Usage
const Punctual = require('so-punctual');
Punctual
.connect({ mongo: { uri: 'mongodb://localhost:27017/punctual' } })
.then((queue) => {
// create a job for John Doe to be executed every 5 minutes
queue.create(5, { name: 'John Doe', { times: 0 });
// process queue
queue.work((job, done) => {
User.updateStats('John Doe')
.then((count) => {
// increment the job's data
job.data.times++;
// process the job less frequently after 10 times
if (job.data.times > 10) {
job.minutes = 10;
}
done();
})
.catch(console.log);
});
})
.catch(console.log);