I receive many documents from an API that I want to write to my database. Unfortunately, the APIs paging is not great and often returns the same documents that have already been inserted. I therefore want to bulk-insert the documents I receive WITHOUT cancelling the whole operation, by just skipping the duplicate ones.
From another answer on this site, this seems easily doable by changing the “ordered” flag to false. However, I do want to know which documents would have been duplicates. How do I print/output/save attempts at inserting duplicate documents (ie duplicate key errors), while not impacting the actual insert operation (i.e. not having to switch to insertOne or something)?