From be969108e96b7186426cca55c8e5df99cfc641c5 Mon Sep 17 00:00:00 2001 From: Lauren Clark Date: Fri, 7 Feb 2020 00:15:21 +0000 Subject: [PATCH] Fix for deprecation warning (node:9521) 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. --- scripts/trymongo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/trymongo.js b/scripts/trymongo.js index 9b674d49..c0830cc6 100644 --- a/scripts/trymongo.js +++ b/scripts/trymongo.js @@ -10,7 +10,7 @@ const url = 'mongodb://localhost/issuetracker'; function testWithCallbacks(callback) { console.log('\n--- testWithCallbacks ---'); - const client = new MongoClient(url, { useNewUrlParser: true }); + const client = new MongoClient(url, { useUnifiedTopology: true }); client.connect(function(err, client) { if (err) { callback(err); @@ -46,7 +46,7 @@ function testWithCallbacks(callback) { async function testWithAsync() { console.log('\n--- testWithAsync ---'); - const client = new MongoClient(url, { useNewUrlParser: true }); + const client = new MongoClient(url, { useUnifiedTopology: true }); try { await client.connect(); console.log('Connected to MongoDB');