-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Dependencies): Upgrades mongodb driver to ^4.7.0 (LLC-1690) (#314)
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
1 parent
9d8050b
commit 0a529af
Showing
14 changed files
with
142 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ notes.md | |
.vscode | ||
dist | ||
coverage | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.