On my local machine i connect to mongoDb "tasksdb" database this way:
var server = new Server('localhost', 27017, {auto_reconnect: true, });
db = new Db('tasksdb', server);
db.open(function(err, db) {
if(!err) {
console.log("Connected to 'tasksdb' database");
db.collection('tasks', {safe:true}, function(err, collection) {
if (err) {
console.log("The 'tasks' collection doesn't exist. Creating it with sample data...");
populateDB();
}
});
}
});
how to force it to work on heroku ? I tried:
var server = new Server(process.env.MONGOLAB_URI, process.env.PORT, {auto_reconnect: true, });
db = new Db('heroku_mydatabase', server);
but it doesn't work. On each example in web people use "connect" but i want to do it this way. Is it possible ?