mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-22 03:37:53 +08:00
Fix agenda constructor options
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import Agenda = require("agenda");
|
||||
import { Db, Server } from "mongodb";
|
||||
import { Db, Server, MongoClient } from "mongodb";
|
||||
|
||||
var mongoConnectionString = "mongodb://127.0.0.1/agenda";
|
||||
|
||||
(async () => {
|
||||
var agenda = new Agenda({ db: { address: mongoConnectionString } });
|
||||
var agenda = new Agenda({
|
||||
mongo: (await MongoClient.connect(mongoConnectionString)).db(),
|
||||
db: { collection: 'agenda-jobs' },
|
||||
});
|
||||
|
||||
agenda.define<{ foo: Error }>('delete old users', (job, done) => {
|
||||
done(job.attrs.data.foo)
|
||||
|
||||
17
types/agenda/index.d.ts
vendored
17
types/agenda/index.d.ts
vendored
@@ -203,17 +203,7 @@ declare namespace Agenda {
|
||||
/**
|
||||
* Specifies that Agenda should be initialized using and existing MongoDB connection.
|
||||
*/
|
||||
mongo?: {
|
||||
/**
|
||||
* The MongoDB database connection to use.
|
||||
*/
|
||||
db: Db;
|
||||
|
||||
/**
|
||||
* The name of the collection to use.
|
||||
*/
|
||||
collection?: string;
|
||||
}
|
||||
mongo?: Db;
|
||||
|
||||
/**
|
||||
* Specifies that Agenda should connect to MongoDB.
|
||||
@@ -221,8 +211,10 @@ declare namespace Agenda {
|
||||
db?: {
|
||||
/**
|
||||
* The connection URL.
|
||||
* Required when using `db` option to connect.
|
||||
* Not required when an existing connection is passed as `mongo` property.
|
||||
*/
|
||||
address: string;
|
||||
address?: string;
|
||||
|
||||
/**
|
||||
* The name of the collection to use.
|
||||
@@ -231,6 +223,7 @@ declare namespace Agenda {
|
||||
|
||||
/**
|
||||
* Connection options to pass to MongoDB.
|
||||
* Not required when an existing connection is passed as `mongo` property.
|
||||
*/
|
||||
options?: any;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user