From 92e42701eeb9d1891bb6b9c82a5bf20cb605afbf Mon Sep 17 00:00:00 2001 From: Coroliov Oleg <1880059+ruscon@users.noreply.github.com> Date: Thu, 5 Sep 2019 15:25:06 +0300 Subject: [PATCH] feat: add mongodb `useUnifiedTopology` config parameter (#4684) --- ormconfig.circleci.json | 3 ++- ormconfig.json.dist | 3 ++- ormconfig.travis.json | 3 ++- src/driver/mongodb/MongoConnectionOptions.ts | 6 ++++++ src/driver/mongodb/MongoDriver.ts | 3 ++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ormconfig.circleci.json b/ormconfig.circleci.json index f56a69db61..d52b7b1d13 100644 --- a/ormconfig.circleci.json +++ b/ormconfig.circleci.json @@ -75,6 +75,7 @@ "name": "mongodb", "type": "mongodb", "database": "test", - "useNewUrlParser": true + "useNewUrlParser": true, + "useUnifiedTopology": true } ] diff --git a/ormconfig.json.dist b/ormconfig.json.dist index 1365721d32..db4e2321bb 100644 --- a/ormconfig.json.dist +++ b/ormconfig.json.dist @@ -77,6 +77,7 @@ "type": "mongodb", "database": "test", "logging": false, - "useNewUrlParser": true + "useNewUrlParser": true, + "useUnifiedTopology": true } ] diff --git a/ormconfig.travis.json b/ormconfig.travis.json index bb61533d70..fb1a1d47eb 100644 --- a/ormconfig.travis.json +++ b/ormconfig.travis.json @@ -76,6 +76,7 @@ "name": "mongodb", "type": "mongodb", "database": "test", - "useNewUrlParser": true + "useNewUrlParser": true, + "useUnifiedTopology": true } ] diff --git a/src/driver/mongodb/MongoConnectionOptions.ts b/src/driver/mongodb/MongoConnectionOptions.ts index f8fe8e426e..845f3f718c 100644 --- a/src/driver/mongodb/MongoConnectionOptions.ts +++ b/src/driver/mongodb/MongoConnectionOptions.ts @@ -321,4 +321,10 @@ export interface MongoConnectionOptions extends BaseConnectionOptions { * Determines whether or not to use the new url parser. Default: false */ readonly useNewUrlParser?: boolean; + + /** + * Determines whether or not to use the new Server Discovery and Monitoring engine. Default: false + * https://github.com/mongodb/node-mongodb-native/releases/tag/v3.2.1 + */ + readonly useUnifiedTopology?: boolean; } diff --git a/src/driver/mongodb/MongoDriver.ts b/src/driver/mongodb/MongoDriver.ts index beb067380a..1de0187f2a 100644 --- a/src/driver/mongodb/MongoDriver.ts +++ b/src/driver/mongodb/MongoDriver.ts @@ -192,7 +192,8 @@ export class MongoDriver implements Driver { "auto_reconnect", "minSize", "monitorCommands", - "useNewUrlParser" + "useNewUrlParser", + "useUnifiedTopology" ]; // -------------------------------------------------------------------------