My goal is to create function which add multiple, but only unique documents. I have a function which adds multiple documents, but it stops with error when in array is even one not unique document.
I suppose that I can make check IF document is unique in function and then command to not create this document, but I feel like this solution duplicates index’s with unique terms behavior.
Your supposition is correct: you would have to test for the existence of each new document prior to trying to create it.
To do this, you would need to extract the values from the flat object that the covering unique index uses in its terms definitions, call Match, and if there is a result, avoid creating the document.