amark / mongous

Simple MongoDB driver for Node.js with jQuery like syntax.
MIT License
246 stars 30 forks source link

Error handling and configuration #24

Closed eaigner closed 12 years ago

eaigner commented 12 years ago

I can't find anything on mongous' error handling mechanism. I dug through the code, but it's not exactly easy to read.

Could you please update the README or Wiki with how errors are handled, and how mongous can be configured to e.g. set a custom mongo host, port, auto-reconnect and that sort of stuff?

As far as I can tell errors are only logged, is that correct?

amark commented 12 years ago

Hey, sorry this is not very clear in the docs.

All you need to do is use the "getLastError" operation command, example:

> $('Accelsor.$cmd').find({getlasterror:1},1,function(r){console.log(r)})
true
> { documents: [ { n: 0, connectionId: 15, err: null, ok: 1 } ],
  requestId: 17,
  responseTo: 58199,
  responseFlag: 8,
  cursorID: { low_: 0, high_: 0 },
  startingFrom: 0,
  numberReturned: 1 }

Check out the "Operations" part of the readme, then see the getLastError command in MongoDB's docs:

http://www.mongodb.org/display/DOCS/getLastError+Command

Does this answer your issue on errors?

amark commented 12 years ago

I haven't personally used the host/port/auto-reconnect, so I am not sure if they work. This needs to get investigated, but could you please open it as an another issue in the meanwhile?