mikowals/batch-insert

Syntax of error/res parameters for the callback ?

Closed this issue · 1 comments

Not sure if something changed recently or it always was like this, but how do you differentiate between the error or result that gets returned.

Seems like the version where there isn't an error returns -> {"result":{"ok":<number of items inserted successfully>,"n":<total number of items tried to insert>},"ops":[{ thing inserted }, ... ], ,"insertedCount":<number of items inserted>,"insertedIds":["ids of items inserted", ... ]}

What's the easiest way to distinguish between that and an actual error ? Also why not set it up so that it returns the standard callback combo of (error, result) where if the error is undefined there wasn't any error and then return the result. Whereas if there is an error it's an object and result contains the same info as it does now.

The expected behavior is the standard error or result. Could you provide more information and ideally a reproduction?

Is this on client or server? What does core insert return if used the same way to insert one document?