From f536f2255f125a714e5a3228d973ae8de4bc72ce Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Wed, 25 Nov 2020 15:36:17 +0100 Subject: [PATCH] Amend connection code. --- test/tools/mongoDBUtils.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/tools/mongoDBUtils.js b/test/tools/mongoDBUtils.js index 5d6052f..5fc1e31 100644 --- a/test/tools/mongoDBUtils.js +++ b/test/tools/mongoDBUtils.js @@ -27,16 +27,14 @@ const async = require('async'); function cleanDb(host, name, callback) { const url = 'mongodb://' + host + ':27017/' + name; - MongoClient.connect( - url, - function(err, db) { - if (db) { - db.dropDatabase(); + MongoClient.connect(url, { useNewUrlParser: true }, function (err, db) { + if (db && db.db()) { + db.db().dropDatabase(function (err, result) { db.close(); - } - callback(); + callback(); + }); } - ); + }); } function cleanDbs(host, callback) {