Skip to content

Commit

Permalink
Add support for protocol to be 'monogodb+srv'
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Sep 12, 2018
1 parent bdad30a commit 695bb20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions lib/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand All @@ -68,7 +72,8 @@ function generateMongoDBURL(options) {
);
} else {
return (
'mongodb://' +
options.protocol +
'://' +
options.hostname +
':' +
options.port +
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 695bb20

Please # to comment.