Skip to content

Instantly share code, notes, and snippets.

@cronopio
Created November 8, 2012 18:23
Show Gist options
  • Save cronopio/4040571 to your computer and use it in GitHub Desktop.
Save cronopio/4040571 to your computer and use it in GitHub Desktop.
//
// Lets take as example the next Mongodb URI
// mongodb://nodejitsu:[email protected]:10047/nodejitsudb54463349176
// mongodb://username:passwd@hostname:port/datababaseName
//
// So the code should looks like
var mongodb = require('mongodb');
var db = new mongodb.Db('nodejitsudb544633491762',
new mongodb.Server('alex.mongohq.com', 10047, {})
);
db.open(function (err, db_p) {
if (err) { throw err; }
db.authenticate('nodejitsu', '684e3def50116af8c8ab032f65230fac', function (err, replies) {
// You are now connected and authenticated.
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment