i made many times questions about connections on mongodb, i cant understand many things yet, but i try...
with this connection...
db.collection('usuarios').insert(campos,{safe:true}, function(err, result)
i get a safe connection.... but mongodb pull me this warning
========================================================================================
= Please ensure that you set the default safe variable to one of the =
= allowed values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}] =
= the default value is false which means the driver receives does =
= return the information of the success/error of the insert/update/remove =
= =
= ex: new Db(new Server('localhost', 27017), {safe:true}) =
= =
= http://www.mongodb.org/display/DOCS/getLastError+Command =
= =
= The default of false will change to true in the near future =
= =
= This message will disappear when the default safe is set on the driver Db =
========================================================================================
so i try this way...
var db = mongo.db("root:toor@127.0.0.1:27017/cordoba",{safe:true});
db.collection('usuarios').insert(campos,{new:true}, function(err, result)
but im not sure if this is a safe:true connection so i put like this
var db = mongo.db("root:toor@127.0.0.1:27017/cordoba",{safe:true});
db.collection('usuarios').insert(campos,{safe:true},{new:true}, function(err, result)
may be that way is safe:true but when i put safe:true before new:true mongodb returns me the old var, so i put safe:true after new:true
var db = mongo.db("root:toor@127.0.0.1:27017/cordoba",{safe:true});
db.collection('usuarios').insert(campos,{new:true},{safe:true}, function(err, result)
and works right but im not sure if it is safe:true, so i try put safe:true in new:true object like this
var db = mongo.db("root:toor@127.0.0.1:27017/cordoba",{safe:true});
db.collection('usuarios').insert(campos,{new:true,safe:true},function(err, result)
i thought that mongdb freaks out! but nothing... no error no nothing .... so i dont know how can i know when mongodb is using safe:true or not safe:true...
how can i know that??
the api is no longer {safe: true}
but {w: 1}
http://mongodb.github.com/node-mongodb-native/api-generated/db.html
var db = mongo.db('mongodb://127.0.0.1:27017/test', {w: 1})
{safe: true}
will still work, but it's deprecated. if you set it at the DB level, you don't need to set it at the collection.insert()
level.
the api signature for insert is insert(docs[, options][, callback])
, so you should only have one options object.
also, there is no {new: true}
options for collection.insert
.
so basically, you don't need to set any options (on insert).