diff --git a/etl/js/lib/dataset_processor.js b/etl/js/lib/dataset_processor.js index 682ff5f8e4..edb58588d1 100644 --- a/etl/js/lib/dataset_processor.js +++ b/etl/js/lib/dataset_processor.js @@ -240,9 +240,7 @@ DatasetProcessor.prototype.process = function (totalCores, coreIndex) { var self = this; var multiCore = totalCores !== undefined && coreIndex !== undefined; if (this.dataset.input.dbEngine == 'mongodb') { - var uri_decode_auth = this.dataset.input.config.uri.indexOf('@') > -1; - - MongoClient.connect(self.dataset.input.config.uri, {native_parser: true, uri_decode_auth: uri_decode_auth}, function(err, db) { + MongoClient.connect(self.dataset.input.config.uri, { useNewUrlParser: true }, function (err, client) { if (err) { self.emit("error", self.dataset.name + ': ' + "MongoClient Open Error: " + util.inspect(err)); self._processEnded = true; @@ -250,6 +248,9 @@ DatasetProcessor.prototype.process = function (totalCores, coreIndex) { return; } + self.client = client; + var db = client.db(); + self.emit('message', self.dataset.name + ': connected to database \'' + db.databaseName + '\''); //look for jobs that haven't been processed yet, @@ -267,8 +268,7 @@ DatasetProcessor.prototype.process = function (totalCores, coreIndex) { return; } - self.db = db; - self.collection = self.db.collection(self.dataset.input.config.collection); + self.collection = db.collection(self.dataset.input.config.collection); // Ensure the query is indexed var indexParams = {}; @@ -378,8 +378,8 @@ DatasetProcessor.prototype.onEndProcess = function () { if (this.stats.currentlyMarking === 0) { this.mysqlPool.end(); this.emit('message', this.dataset.name + ': mysqlPool closed'); - if (this.db) { - this.db.close(); + if (this.client) { + this.client.close(true); this.emit('message', this.dataset.name + ': mongo connection closed'); } diff --git a/etl/js/package.json b/etl/js/package.json index 0646a4a2a0..99234ccac3 100644 --- a/etl/js/package.json +++ b/etl/js/package.json @@ -8,7 +8,7 @@ "dependencies": { "cloneextend": "0.0.x", "ini": "1.2.x", - "mongodb": "2.1.x", + "mongodb": "3.1.x", "mysql": "2.2.x", "tv4": "^1.0.13", "winston": "0.7.x",