From 39c911a4aee9ae421efe6c8c4476348e6302797b Mon Sep 17 00:00:00 2001 From: Samuel Oltz Date: Thu, 11 Oct 2018 15:49:25 -0400 Subject: [PATCH 1/2] move require mongo into connected() if !options.connection --- lib/persistence/mongo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/persistence/mongo.js b/lib/persistence/mongo.js index 1bbc0c2..e7dedea 100644 --- a/lib/persistence/mongo.js +++ b/lib/persistence/mongo.js @@ -26,8 +26,6 @@ OTHER DEALINGS IN THE SOFTWARE. var AbstractPersistence = require("./abstract"); var escape = require('escape-string-regexp'); -var mongo = require('mongodb'); -var MongoClient = mongo.MongoClient; var util = require("util"); var steed = require("steed")(); var Matcher = require("./matcher"); @@ -167,6 +165,8 @@ function MongoPersistence(options, done) { if (options.connection) { connected(null, this.options.connection); } else { + const mongo = require('mongodb'); + const MongoClient = mongo.MongoClient; MongoClient.connect(this.options.url, this.options.mongo, connected); } } From fac72496a3015053e4ae5b90c82ccadef968f062 Mon Sep 17 00:00:00 2001 From: Samuel Oltz Date: Thu, 11 Oct 2018 16:02:04 -0400 Subject: [PATCH 2/2] fix use of const with mongo --- lib/persistence/mongo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/persistence/mongo.js b/lib/persistence/mongo.js index e7dedea..183ed18 100644 --- a/lib/persistence/mongo.js +++ b/lib/persistence/mongo.js @@ -165,8 +165,8 @@ function MongoPersistence(options, done) { if (options.connection) { connected(null, this.options.connection); } else { - const mongo = require('mongodb'); - const MongoClient = mongo.MongoClient; + var mongo = require('mongodb'); + var MongoClient = mongo.MongoClient; MongoClient.connect(this.options.url, this.options.mongo, connected); } }