Skip to content

Commit

Permalink
Merge pull request #1462 from telefonicaid/fix/warn_mongoose
Browse files Browse the repository at this point in the history
set useUnifiedTopology = true to remove warn
  • Loading branch information
fgalan authored Sep 22, 2023
2 parents 0e55b4b + be044cb commit 8dc9b8f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
3 changes: 2 additions & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Upgrade mongodb dev dep from 4.17.0 to 4.17.1
- Fix: remove mongo `DeprecationWarning: current Server Discovery and Monitoring engine is deprecated` by setting `useUnifiedTopology = true`
- Upgrade mongodb dev dep from 4.17.0 to 4.17.1
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

0 comments on commit 8dc9b8f

Please sign in to comment.