Mark Mark - 9 days ago 4
Node.js Question

How do I connect to mongodb with node.js (and authenticate)?

How do I connect to mongodb with node.js?

I have the node-mongodb-native driver.

There's apparently 0 documentation.

Is it something like this?

var mongo = require('mongodb/lib/mongodb');
var Db= new mongo.Db( dbname, new mongo.Server( '', 27017, {}), {});

Where do I put the username and the password?

Also how do I insert something?



Per the source:

After connecting:

Db.authenticate(user, password, function(err, res) {
  // callback