Skip to content

Instantly share code, notes, and snippets.

@imaustink
Created March 3, 2016 17:21
Show Gist options
  • Save imaustink/f16a80b1b4d70f16e8c5 to your computer and use it in GitHub Desktop.
Save imaustink/f16a80b1b4d70f16e8c5 to your computer and use it in GitHub Desktop.
Simple Mongo DB connection URL generator in JavaScript
function mongoURL(options) {
options = options || {};
var URL = 'mongodb://';
if (options.password && options.username) URL += options.username + ':' + options.password + '@';
URL += (options.host || 'localhost') + ':';
URL += (options.port || '27017') + '/';
URL += (options.database || 'admin');
return URL;
}
@achtan
Copy link

achtan commented Aug 12, 2022

Hi, I created a simple GUI tool for building MongoDB URI https://manage.mingo.io/tool/mongodb-uri-builder

@Itax67
Copy link

Itax67 commented Feb 23, 2024

Very good

@Itax67
Copy link

Itax67 commented Feb 23, 2024

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment