Insert values into MongoDB (Node.js, mongojs, express)

Respected ppl ...

Im trying to insert my jsons which im building into mongodb ...

     var newjson = JSON.stringify(json);

     console.log(newjson);

     db.mongostuds.save(newjson, function(err, saved) {
         if( err || !saved ) console.log("Record not saved");
         else console.log("Record saved");
     }); 

my connection is as follows :

var databaseUrl = "vtu";
var collections = ["mongostuds"]
var db = require("mongojs").connect(databaseUrl, collections); 

The db gets created but the data does not get inserted ....

I even tried removing my json and doing simple stuff like :

db.mongostuds.save({username : "admin"}, function(err, saved) {
    if( err || !saved ) { console.log("Record not saved"); }
    else { console.log("Record saved"); }
});

But still the record is not inserted ....

And ya i get "Record saved" in console log ...

This is the entire code : https://github.com/SkyKOG/luckyvturesults.com/blob/master/app.js

Kindly do help ...

Thanks

Try to give DatabaseUrl in below form if your mongo server is not running on default host and port:

"username:password@host:port/dbName".

This code block works fine for me:

var databaseUrl = "vtu";
var collections = ["mongostuds"]
var db = require("mongojs").connect(databaseUrl, collections); 


db.mongostuds.save({username : "admin"}, function(err, saved) {
    if( err || !saved ) { console.log("Record not saved"); }
    else { console.log("Record saved"); }
});

Try running that without all the YQL and Express and other stuff.