-
-
Save Itax67/caf0cee9cd3e0536fe49c52c4e86f2c6 to your computer and use it in GitHub Desktop.
Simple Mongo DB connection URL generator in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment