1602/jugglingdb — pull request #150 by fshost (2012-11-08 21:36:56+00:00)
Title: update mongodb adapter

when using the mongodb adapter, I was getting the following message on my console:

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 not
return the information of the success/error of the insert/update/remove

ex: new Db(new Server('localhost', 27017), {safe:false})

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

There was no way to pass the safe option to the jugglingdb mongodb adapter, so I modified the adapter to implement the ability to pass a 'safe' option, with a default of false, which was already the default it would set after giving you the warning message. By explicitly setting it to a value, this removes the warning, which only occurs if safe is undefined.

examples:

// no need to change your code as existing method still works fine
var schema = new Schema('mongodb', { url: 'mongodb://localhost' })

// driver will ensure writes have no errors before returning (slower)
var schema = new Schema('mongodb', { url: 'mongodb://localhost', safe: true });

// recommended for highly critical writes
var schema = new Schema('mongodb', { url: 'mongodb://localhost', safe: { j:true, w:'majority', wtimeout:10000 }})

You can set safe to any of the values mentioned in the message above. More info can be found here:http://www.mongodb.org/display/DOCS/getLastError+Command.