Correctly type fluent returns for extension

This commit is contained in:
Matthew Bull 2018-02-20 13:39:48 +00:00
parent 070eb128b8
commit a01ac1b2ca
2 changed files with 15 additions and 10 deletions

View File

@ -1,10 +1,10 @@
import Agenda = require("agenda");
import { Db, Server } from "mongodb";
var mongoConnectionString = "mongodb://127.0.0.1/agenda";
var agenda = new Agenda({ db: { address: mongoConnectionString } });
agenda.define('delete old users', (job, done) => {
});
@ -102,4 +102,9 @@ job.remove(function(err) {
if (!err) console.log("Successfully removed job from collection");
})
class ExtendedAgenda extends Agenda {
async start() { }
}
const extendedAgenda: ExtendedAgenda = new ExtendedAgenda()
.mongo(new Db('some-database', new Server('host.name', 0)))

View File

@ -31,57 +31,57 @@ declare class Agenda extends EventEmitter {
/**
* Connect to the specified MongoDB server and database.
*/
database(url: string, collection?: string, options?: any, cb?: ResultCallback<Collection>): Agenda;
database(url: string, collection?: string, options?: any, cb?: ResultCallback<Collection>): this;
/**
* Initialize agenda with an existing MongoDB connection.
*/
mongo(db: Db, collection?: string, cb?: ResultCallback<Collection>): Agenda;
mongo(db: Db, collection?: string, cb?: ResultCallback<Collection>): this;
/**
* Sets the agenda name.
*/
name(value: string): Agenda;
name(value: string): this;
/**
* Sets the interval with which the queue is checked. A number in milliseconds or a frequency string.
*/
processEvery(interval: string | number): Agenda;
processEvery(interval: string | number): this;
/**
* Takes a number which specifies the max number of jobs that can be running at any given moment. By default it
* is 20.
* @param value The value to set.
*/
maxConcurrency(value: number): Agenda;
maxConcurrency(value: number): this;
/**
* Takes a number which specifies the default number of a specific job that can be running at any given moment.
* By default it is 5.
* @param value The value to set.
*/
defaultConcurrency(value: number): Agenda;
defaultConcurrency(value: number): this;
/**
* Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is
* 0 for no max.
* @param value The value to set.
*/
lockLimit(value: number): Agenda;
lockLimit(value: number): this;
/**
* Takes a number which specifies the default number of a specific job that can be locked at any given moment.
* By default it is 0 for no max.
* @param value The value to set.
*/
defaultLockLimit(value: number): Agenda;
defaultLockLimit(value: number): this;
/**
* Takes a number which specifies the default lock lifetime in milliseconds. By default it is 10 minutes. This
* can be overridden by specifying the lockLifetime option to a defined job.
* @param value The value to set.
*/
defaultLockLifetime(value: number): Agenda;
defaultLockLifetime(value: number): this;
/**
* Returns an instance of a jobName with data. This does NOT save the job in the database. See below to learn