From 695bb2040e0020c0f5f8dffeca5a40d181b20c6e Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Thu, 6 Sep 2018 20:43:42 -0700 Subject: [PATCH] Add support for protocol to be 'monogodb+srv' See https://docs.mongodb.com/manual/reference/connection-string/ --- lib/mongodb.js | 9 +++++++-- package.json | 10 +++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/mongodb.js b/lib/mongodb.js index c8b3aaffa..f90ae37a7 100644 --- a/lib/mongodb.js +++ b/lib/mongodb.js @@ -49,13 +49,17 @@ exports.generateMongoDBURL = generateMongoDBURL; * Generate the mongodb URL from the options */ function generateMongoDBURL(options) { + // See https://docs.mongodb.com/manual/reference/connection-string/#dns-seedlist-connection-format + // It can be `mongodb+srv` now. + options.protocol = options.protocol || 'mongodb'; options.hostname = options.hostname || options.host || '127.0.0.1'; options.port = options.port || 27017; options.database = options.database || options.db || 'test'; var username = options.username || options.user; if (username && options.password) { return ( - 'mongodb://' + + options.protocol + + '://' + username + ':' + options.password + @@ -68,7 +72,8 @@ function generateMongoDBURL(options) { ); } else { return ( - 'mongodb://' + + options.protocol + + '://' + options.hostname + ':' + options.port + diff --git a/package.json b/package.json index e0a4b2fdb..9e7734cf5 100644 --- a/package.json +++ b/package.json @@ -26,23 +26,23 @@ ], "license": "MIT", "dependencies": { - "async": "^2.6.0", + "async": "^2.6.1", "bson": "^1.0.6", "debug": "^3.1.0", "loopback-connector": "^4.5.0", - "mongodb": "^3.0.1", + "mongodb": "^3.1.4", "strong-globalize": "^4.1.1" }, "devDependencies": { "benchmark": "^2.1.4", - "bluebird": "^3.5.1", + "bluebird": "^3.5.2", "eslint": "^5.1.0", "eslint-config-loopback": "^10.0.0", - "loopback-datasource-juggler": "^3.0.0", + "loopback-datasource-juggler": "^3.23.0", "memwatch-next": "^0.3.0", "mocha": "^5.2.0", "rc": "^1.2.8", - "semver": "^5.5.0", + "semver": "^5.5.1", "should": "^13.2.1", "sinon": "^6.1.3" }