i have a connection with mongoskin and nodejs
var db = mongo.db("root:toor@127.0.0.1:27017/cordoba");
but i dont know wich is the best practice in this case....
db.collection('usuarios').insert(campos,{safe:true}, function(err, result)
i want to insert campos in mongodb, im using safe:true... so what happends if i use safe:false, and what is the best practice ...
this...
var db = mongo.db("root:toor@127.0.0.1:27017/cordoba");
db.collection('usuarios').insert(campos,{safe:true}, function(err, result)
or this...
var db = mongo.db("root:toor@127.0.0.1:27017/cordoba",{safe:true});
db.collection('usuarios').insert(campos, function(err, result)
tnx all
{safe:true} assures you that the callback function will get executed only after the insertion is done and {safe:false} does not guarantee that. I always use {safe:true}, just to make sure that I have the most up to date version of the DB.