Hey everyone
I’m using Golang’s MongoDB driver and I’m facing an issue I would love getting assistance with.
I try running InsertMany()
with Ordered: false
in order to ignore duplicate key errors (I use a unique index for a specific field which should be unique) and keep on inserting all the other documents.
It works perfectly fine (in the happy flow ), however I’m not sure it’s possible to handle errors if multiple different errors arise in the same insertion - the
mongo.IsDuplicateKeyError()
function seems to return true
even if the insertion returns 10 errors and only 1 of them is duplicate key
Is there any solution I can use to ignore duplicate key errors but still be able to handle other errors, should they occur?
Thank you!