Skip to content

Commit

Permalink
fix(Dependencies): Upgrades mongodb driver to ^4.7.0 (LLC-1690) (#314)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: when using this repo be mindful we now use official MongoDB TS Types which are packed with the mongodb driver v4.0.0, so if you're using a version of the mongodb driver that's lower than v4 you will likely be using the mongodb community types @types/mongodb which could clash with the shape of objects now defined in this project (i.e the official MongoDB types). To resolve, you'd likely need to upgrade to use mongodb driver ^4.0.0.
  • Loading branch information
paul-stoner authored Jun 27, 2022
1 parent 9d8050b commit 0a529af
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 139 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ notes.md
.vscode
dist
coverage
.idea
189 changes: 113 additions & 76 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"knex": "^0.19.0",
"lodash": "^4.17.10",
"moment": "^2.22.1",
"mongodb": "^3.0.8",
"mongodb": "^4.7.0",
"morgan": "^1.9.0",
"newrelic": "^7.4.0",
"rulr": "^4.0.2",
Expand All @@ -63,7 +63,6 @@
"@types/knex": "0.15.2",
"@types/lodash": "4.14.141",
"@types/mocha": "2.2.48",
"@types/mongodb": "3.0.18",
"@types/morgan": "1.7.37",
"@types/node": "^17.0.35",
"@types/uuid": "3.4.5",
Expand Down
2 changes: 1 addition & 1 deletion src/knexRepo/utils/match.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* tslint:disable no-invalid-this no-use-before-declare no-this max-file-line-count */
/* tslint:disable no-invalid-this no-this max-file-line-count */
import { QueryBuilder } from 'knex';
import { isObject } from 'lodash';
import InvalidOp from '../../errors/InvalidOp';
Expand Down
1 change: 0 additions & 1 deletion src/memoryRepo/utils/match.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable no-use-before-declare */
import { includes, isNull, isObject, isUndefined } from 'lodash';
import InvalidOp from '../../errors/InvalidOp';

Expand Down
11 changes: 5 additions & 6 deletions src/mongoRepo/utils/connectToDb/createConnection.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { MongoClient } from 'mongodb';
import Config from './Config';
import Connection from './Connection';
import handleJoiningReplica from './handleJoiningReplica';
import handleLeavingReplica from './handleLeavingReplica';
import retryConnection from './retryConnection';

export default async (config: Config, retries = 0): Promise<Connection> => {
try {
const client = await MongoClient.connect(config.url);
const db = client.db(config.dbName);

config.logger.info(`Created new Mongo connection`);
(db as any).s.topology.once('left', handleLeavingReplica(config));
(db as any).s.topology.once('joined', handleJoiningReplica(config));

return { client, db };
} catch (err: any) {
config.logger.error(`Failed Mongo connection: ${err.message}`);
} catch (error: any) {
config.logger.error(`Failed Mongo connection: ${error.message}`);

return retryConnection(config, retries + 1);
}
};
15 changes: 0 additions & 15 deletions src/mongoRepo/utils/connectToDb/getConnection.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/mongoRepo/utils/connectToDb/handleJoiningReplica.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/mongoRepo/utils/connectToDb/handleLeavingReplica.ts

This file was deleted.

Loading

0 comments on commit 0a529af

Please sign in to comment.