Created
September 27, 2013 00:36
-
-
Save pbojinov/6722628 to your computer and use it in GitHub Desktop.
MongoDB Connection From Node.js To MongoLab
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
| //http://tamsler.blogspot.com/2012/06/mongodb-connection-from-nodejs-to.html | |
| var mongo = require('mongodb'); | |
| var Server = mongo.Server; | |
| var Db = mongo.Db; | |
| var server = new Server('ds1234.mongolab.com', 12345, {auto_reconnect : true}); | |
| var db = new Db('db-name', server); | |
| db.open(function(err, client) { | |
| client.authenticate('username', 'password', function(err, success) { | |
| // Do Something ... | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment