Skip to content

Commit

Permalink
Merge pull request #712 from jpwhite4/updatemongo
Browse files Browse the repository at this point in the history
Update Mongo Driver to a currently maintained version
  • Loading branch information
jpwhite4 authored Nov 8, 2018
2 parents f3cf425 + 3f86ccf commit 6149358
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions etl/js/lib/dataset_processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,17 @@ 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;
self.onEndProcess();
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,
Expand All @@ -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 = {};
Expand Down Expand Up @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion etl/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6149358

Please sign in to comment.