Skip to content

Commit

Permalink
fix: use new mongo stack
Browse files Browse the repository at this point in the history
  • Loading branch information
simllll committed Oct 12, 2020
1 parent 4b683e7 commit a2e74a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hokify/agenda",
"version": "4.0.5",
"version": "4.0.6",
"description": "Light weight job scheduler for Node.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
13 changes: 11 additions & 2 deletions src/JobDbRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ export class JobDbRepository {

this.collection = db.collection(collection);
log(
`connected with collection: ${collection}, collection size: ${await this.collection.estimatedDocumentCount()}`
`connected with collection: ${collection}, collection size: ${
typeof this.collection.estimatedDocumentCount === 'function'
? await this.collection.estimatedDocumentCount()
: '?'
}`
);

if (this.connectOptions.ensureIndex) {
Expand Down Expand Up @@ -183,7 +187,12 @@ export class JobDbRepository {
reconnectTries: Number.MAX_SAFE_INTEGER
};

const client = await MongoClient.connect(url, { ...reconnectOptions, ...options });
const client = await MongoClient.connect(url, {
...reconnectOptions,
...options,
useNewUrlParser: true,
useUnifiedTopology: true
});

return client.db();
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Agenda extends EventEmitter {

private jobProcessor?: JobProcessor;

private ready: Promise<unknown>;
private ready: Promise<void>;

getRunningStats() {
if (!this.jobProcessor) {
Expand Down

0 comments on commit a2e74a9

Please sign in to comment.