Connecting with MongoDB native driver
I wrote following code to connect mongodb through native driver which has been install with npm install mongodb --save
const MongoClient = require("mongodb").MongoClient;
const url = "mongodb://127.0.0.1:27017";
const dbName = "game-of-thrones";
let db;
MongoClient.connect(
url,
{ useNewUrlParser: true },
(err, client) => {
if (err) return console.log(err);
db = client.db(dbName);
console.log(`Connected MongoDB: ${url}`);
console.log(`Database: ${dbName}`);
}
);
When I write on the terminal node server.js
I got following error
(node:3500) 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. Connected MongoDB: mongodb://127.0.0.1:27017 Database: game-of-thrones
The database is connected, but how can I get rid out from the warning