I need to access my mongodb from node with login and pass. Here how I do it now:
var mongo = require('mongodb'),
Server = mongo.Server,
Db = mongo.Db,
ObjectID = require('mongodb').ObjectID;
var BSON = mongo.BSONPure;
var server = new Server('localhost', 27017, {
auto_reconnect: true
});
var db = new Db('mybase', server);
What should I do to authentificate with password?
Call db.authenticate
after opening a connection to the server.
db.open(function(err, db) {
db.authenticate('username', 'password', function(err, result) {
...
});
});
});