InsertBulk aborts transaction even if unordered

Hi people, im trying to use InsertBulk to get the error object that tells me which documents failed, with the intention of avoiding doing field uniqueness checks. But i find that inside transaction InsertBulk aborts transaction and only retrieves first document that failed. Forcing me to have to do uniqueness checks before calling InsertBulk when working with transaction.
There is any workaround for this that avoids me to do uniqueness checks?
If not then why InsertBulk its working like this?
Here a stackoverflow link related to this topic:

I mean yes i know this is how its inteded to work since its stated in docs, but why? wouldn’t be more useful to retrieve full list of docs that failed at least?
Ty.
AgCaliva

@James_Kovacs hi there im not sure where i have to write to make arrive this to mongo devs, sorry to tag you but i dont know who i should write to or how. There is no issues section in repo so i dont know. Ty for your time.

Fundamentally this isn’t a question about the Node Driver or even drivers in general but is a question about server insert behaviour within transactions. In order for drivers to return the result of all uniqueness checks, the server would have to return those failures to the driver.

The easiest way to view the information returned by the server is to use insert server command via runCommand. Then you can see the server response directly.

Hope that helps!

Sincerely,
James

1 Like

Yes, i have seen that someone already tried to suggest this improvement, since its a bad design in 2020, its sad.