From 2ce5a2ef2df0105b80b4861e1d27f09c96bfcf2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Fri, 25 Aug 2017 11:26:51 +0200 Subject: [PATCH] Adds the agenda property to Job. --- types/agenda/agenda-tests.ts | 10 ++++++---- types/agenda/index.d.ts | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/types/agenda/agenda-tests.ts b/types/agenda/agenda-tests.ts index 8c5e3e19bb..964eb1b836 100644 --- a/types/agenda/agenda-tests.ts +++ b/types/agenda/agenda-tests.ts @@ -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'); diff --git a/types/agenda/index.d.ts b/types/agenda/index.d.ts index fe8ecc45a6..d170a6f6f1 100644 --- a/types/agenda/index.d.ts +++ b/types/agenda/index.d.ts @@ -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 // 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.