Driver 'result' object and error handling? #10554
jhunterkohler
started this conversation in
General
Replies: 1 comment 1 reply
-
Does the MongoDB Node driver send back a result with |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As you probably all know methods that more directly access the underlying driver like
Model.prototype.updateOne()
result results similar to:I have two quick questions since I've been very confused on how to handle the raw results:
Does mongoose throw and error for
ok: 0
?Obviously the Node.JS MongoDB driver results
ok: 0
if an error occurs while writing, but does Mongoose recognize this internally, or just pass back the result?How should I handle this?
What is the typical pattern for handling this type of result? I feel that, due to repetitiveness of checking the response for such a simple operation, I am missing some patterned solution. Also, it seems to me that
ok: 0
would signify something that is out of my control to handle, because it is something wrong in the database itself, leading to confusion of wether I should notify users that a server error has occurred over, or if there could be some better way to get information.Beta Was this translation helpful? Give feedback.
All reactions