I am trying to connect to mongoHQ from my node.js app. Here is the code I am using:
var databaseUrl = "mongodb://fishcuss:MyPassword@alex.mongohq.com:10015/app9759558"
var collections = ["users"]
var db = require("mongojs").connect(databaseUrl, collections);
exports.register = function(req, res){
console.log("Register hit")
var user = req.body;
db.users.findOne({username:user.username}, function(err, users) {
console.log(err)
console.log(users);
if( err || users) {
res.statusCode = 500;
res.end();
}
else {
console.log("Inserting new user")
user._id = uuid.v4();
user.lists = [];
db.users.insert(user,{},function(){
req.session.user=user
res.write(JSON.stringify(user), 'UTF-8');
res.statusCode = 200;
res.end();
})
} ;
});
};
However I seem to get this error
{ [MongoError: auth fails] name: 'MongoError', errmsg: 'auth fails', ok: 0 }
Which leads me to believe that I am missing something in my connection. Anyone have a hint as to what that might be?
Thanks