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;
}
@ABIDKHAN2626
Copy link

  1. 2

@ABIDKHAN2626
Copy link

Bot

@ABIDKHAN2626
Copy link

abidkhanbaloch3

@ABIDKHAN2626
Copy link

Very good

@ABIDKHAN2626
Copy link

WhatsApp bot

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