Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set useUnifiedTopology = true to remove warn #1462

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix remove mongo DeprecationWarning: current Server Discovery and Monitoring engine is deprecated by adding set useUnifiedTopology = true
fgalan marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions lib/model/dbConn.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function init(host, db, port, options, callback) {
// but not sure if current mongoose version is still using mongodb 3.x internally
// probably mongodb-connectionoptions-test.js needs to be fixed if useNewUrlParser is removed at the end
options.useNewUrlParser = true;
options.useUnifiedTopology = true;
mongoose.set('useCreateIndex', true);
/* eslint-disable-next-line no-unused-vars */
const candidateDb = mongoose.createConnection(url, options, function (error, result) {
Expand Down
48 changes: 32 additions & 16 deletions test/unit/mongodb/mongodb-connectionoptions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ describe('dbConn.configureDb', function () {
expected: {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -88,7 +89,8 @@ describe('dbConn.configureDb', function () {
expected: {
url: 'mongodb://example.com:98765/' + dbConn.DEFAULT_DB_NAME,
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -100,7 +102,8 @@ describe('dbConn.configureDb', function () {
expected: {
url: 'mongodb://example.com:27017/examples',
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -113,7 +116,8 @@ describe('dbConn.configureDb', function () {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
options: {
replicaSet: 'rs0',
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -125,7 +129,8 @@ describe('dbConn.configureDb', function () {
expected: {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -137,7 +142,8 @@ describe('dbConn.configureDb', function () {
expected: {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -154,7 +160,8 @@ describe('dbConn.configureDb', function () {
user: 'user01',
password: 'pass01'
},
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -167,7 +174,8 @@ describe('dbConn.configureDb', function () {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
options: {
authSource: 'admin',
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -190,7 +198,8 @@ describe('dbConn.configureDb', function () {
password: 'pass01'
},
authSource: 'admin',
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -203,7 +212,8 @@ describe('dbConn.configureDb', function () {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
options: {
ssl: true,
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -217,7 +227,8 @@ describe('dbConn.configureDb', function () {
expected: {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME + '?retryWrites=true',
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -235,7 +246,8 @@ describe('dbConn.configureDb', function () {
dbConn.DEFAULT_DB_NAME +
'?retryWrites=true&readPreference=nearest',
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -247,7 +259,8 @@ describe('dbConn.configureDb', function () {
expected: {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -259,7 +272,8 @@ describe('dbConn.configureDb', function () {
expected: {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand All @@ -271,7 +285,8 @@ describe('dbConn.configureDb', function () {
expected: {
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
options: {
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},
Expand Down Expand Up @@ -302,7 +317,8 @@ describe('dbConn.configureDb', function () {
},
authSource: 'admin',
ssl: true,
useNewUrlParser: true
useNewUrlParser: true,
useUnifiedTopology: true
}
}
}
Expand Down