Bulk save - avoid duplicates

Is it possible to save an array of documents into a collection but prevent any duplicates?

I know I can use triggers like beforeSave, but due to the amount of data I want to bulk insert the elements inside an array of objects without having to query the collection for array.length times to check if a document witha certain field value already exists.

If you are using base64 format to save your files, then you can compare base64 data to check for duplicates. Not sure if there is any other way.

You can try the solution in the below thread for multiple files upload.