loopback-connector-mongodb icon indicating copy to clipboard operation
loopback-connector-mongodb copied to clipboard

DeprecationWarning: option useUnifiedTopology to MongoClient.connect

Open herbertscruz opened this issue 7 years ago • 13 comments

(node:9048) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to MongoClient.connect. at parseFn (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/mongodb/lib/operations/connect.js:312:5) at parseConnectionString (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/mongodb/lib/core/uri_parser.js:628:3) at connect (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/mongodb/lib/operations/connect.js:266:3) at ConnectOperation.execute (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/mongodb/lib/operations/connect.js:191:5) at executeOperation (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/mongodb/lib/operations/execute_operation.js:94:26) at MongoClient.connect (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/mongodb/lib/mongo_client.js:216:10) at MongoDB.connect (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/loopback-connector-mongodb/lib/mongodb.js:298:62) at Object.initializeDataSource [as initialize] (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/loopback-connector-mongodb/lib/mongodb.js:115:28) at DataSource.setup (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/loopback-datasource-juggler/lib/datasource.js:502:19) at new DataSource (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/loopback-datasource-juggler/lib/datasource.js:138:8) at Registry.createDataSource (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/loopback/lib/registry.js:364:12) at dataSourcesFromConfig (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/loopback/lib/application.js:570:19) at Function.app.dataSource (/home/herberts/Projects/workspace/aegon/platform-api/node_modules/loopback/lib/application.js:269:14) at /home/herberts/Projects/workspace/aegon/platform-api/node_modules/loopback-boot/lib/executor.js:191:9 at /home/herberts/Projects/workspace/aegon/platform-api/node_modules/loopback-boot/lib/executor.js:282:5 at Array.forEach ()

herbertscruz avatar Aug 20 '19 19:08 herbertscruz

any fix for this issue ! ? datasources.json

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "MongoDB": {
    "host": "localhost",
    "port": 27017,
    "url": "mongodb://localhost:27017/renoom",
    "database": "renoom",
    "password": "",
    "name": "MongoDB",
    "user": "",
    "useNewUrlParser": true,
    "useUnifiedTopology": true,
    "connector": "mongodb"
  }
}

heshamelmasry77 avatar Sep 02 '19 08:09 heshamelmasry77

I'm waiting to approve.

https://github.com/strongloop/loopback-connector-mongodb/pull/541

herbertscruz avatar Sep 04 '19 00:09 herbertscruz

keep in mind that in the case {useUnifiedTopology: true} of connection with mongo never restores https://jira.mongodb.org/browse/NODE-2147

siarheidudko avatar Sep 05 '19 05:09 siarheidudko

Problem Fixed... Use this @herbertscruz Mongodb deprecated current server and engine monitoring method , So you need to use new server and engine monitoring method.. So use

{ useUnifiedTopology:true } mongoose.connect(process.env.test_db, { useUnifiedTopology: true, useNewUrlParser: true, useCreateIndex: true });

Ref: https://stackoverflow.com/a/57900760/11873380

Tamilselvanret avatar Sep 12 '19 06:09 Tamilselvanret

mongoose.connect('mongodb://localhost:27017/', {useNewUrlParser: true, useUnifiedTopology: true}); // for version "5.7.1" - Resolved :)

emersomcarvalho avatar Sep 27 '19 14:09 emersomcarvalho

Is this going to get merged into v3 as well?

carlosconnected avatar Oct 24 '19 16:10 carlosconnected

@carlos-peru Can you cherry-pick the commits and submit a patch for 3.x branch?

raymondfeng avatar Oct 24 '19 16:10 raymondfeng

@raymondfeng done: #548

carlosconnected avatar Oct 30 '19 12:10 carlosconnected

Thanks

adhikmewada avatar Dec 15 '19 14:12 adhikmewada

Thanks a lot :)

Thetchina13 avatar Dec 22 '19 14:12 Thetchina13

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 20 '20 15:02 stale[bot]

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

stale[bot] avatar Mar 05 '20 15:03 stale[bot]

thank you very much for working on this error add this line in my package.json. I can now use useUnifiedTopology. Seriously thank you very much, I was about to upload a fix to my private repository. I save myself a lot of headaches

line: "loopback-connector-mongodb": "git + https: //github.com/strongloop/loopback-connector-mongodb.git#v5.1.0"

rporta avatar Jun 23 '20 23:06 rporta