mongodb-js/connect-mongodb-session

Deprecation warning

tbhaxor opened this issue · 2 comments

I would appreciate if anyone could fix this issue

(node:25954) 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 the MongoClient constructor.

As the warning suggests, if you really want to get rid of it then pass the options object when you're connecting to the database like this:
const URI = 'yourMongoDBURIhere';
mongoose.connect(URI, { useNewUrlParser: true, useUnifiedTopology: true })
Here I'm using 'mongoose' but generally, the syntax wouldn't change much.
EDITED:
Here's how you would 'fix' it without using 'mongoose':
Create a mongoClient like this then connect to the DB as usual.
const mongoClient = new MongoClient(URI, { useNewUrlParser: true, useUnifiedTopology: true });

@phongvu99 THANKS, I ll try this one too