I used db.collection.insert method to add a document in mongodb with function(err,records) callback. Though insertion succeeds (I checked on mongolab the record), records is null so that It throws error at records[0]._id
Is it a node.js bug on nitrous.io which I'm testing ?
MongoClient.connect(uri, function (err, db) {
if (err) {
throw err;
} else {
console.log("successfully connected to the database");
// Insert document in MongoDb Collection
var document = {title:'test',category:'node.js'}
db.collection('tut').insert(document, function(err,records){
//if (err) throw err;
console.log('inserted record id: ' + records[0]._id);
});
}
db.close();
});