Adds the agenda property to Job.

This commit is contained in:
Thomas Corbière 2017-08-25 11:26:51 +02:00
parent 93d659fc39
commit 2ce5a2ef2d
2 changed files with 12 additions and 5 deletions

View File

@ -3,16 +3,16 @@ import * as Agenda from "agenda";
var mongoConnectionString = "mongodb://127.0.0.1/agenda";
var agenda = new Agenda({ db: { address: mongoConnectionString } });
agenda.define('delete old users', (job, done) => {
});
agenda.on('ready', () => {
agenda.every('3 minutes', 'delete old users');
// Alternatively, you could also do:
// Alternatively, you could also do:
agenda.every('*/3 * * * *', 'delete old users');
agenda.start();
@ -81,6 +81,8 @@ agenda.stop(function() {
process.exit(0);
});
job.agenda.now('do the hokey pokey');
job.repeatEvery('10 minutes');
job.repeatAt('3:30pm');

View File

@ -1,4 +1,4 @@
// Type definitions for Agenda v0.8.9
// Type definitions for Agenda v1.0.0
// Project: https://github.com/rschmukler/agenda
// Definitions by: Meir Gottlieb <https://github.com/meirgottlieb>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@ -337,6 +337,11 @@ declare namespace Agenda {
*/
attrs: JobAttributes;
/**
* The agenda that created the job.
*/
agenda: Agenda;
/**
* Specifies an interval on which the job should repeat.
* @param interval A human-readable format String, a cron format String, or a Number.