Passing 'undefined' on failure to select.
When a query finds no record, it passes 'undefined' to the callback (and sets no error). Is this the correct behavior?
I'm certain users of your library are now used to this behavior, and changing it would be a huge (breaking) hassle, but having to handle undeclared values being passed around is... awkward. Doing a typeof check (as opposed to a 'null' check) for returned records doesn't seem like the appropriate way to do things.
Since I checked all the issues, and no-one else is complaining, I'm open to the idea that I'm very wrong and I'm using your library incorrectly.
Is the suggestion to set an error, or to pass a different kind of value? undefined seems to be to be the correct behavior, since "not finding data" is not an error state. Malformed queries, broken databases, and so on are errors, whereas lack of data is a valid value.
what about an empty array or empty object? [] or {}
It's much harder to detect an empty object than it is to detect undefined or null - the latter are falsy, the former is not. I think the current behavior is correct.
Closing; current behavior is correct and matches other libraries.
Thanks for taking the time to address this. My suggestion would be a null, as I am using passport, and passport deauthorizes when null is passed to it's deserializer (probably because MongoDB returns null when no document satisfies a query, and passport is very nosql friendly).
Ultimately, adding one typeof check to my code will be easier than changing your and everyone's code base. Cheers!
It also make async lib to not work how expected, better will be null.