S
S
Stanislav2016-01-01 14:14:50
Node.js
Stanislav, 2016-01-01 14:14:50

How to swallow duplicate key errors in mongodb with insertMany?

Can someone tell me, I didn’t find something in the docks, or I didn’t understand anything.
It requires saving an array of documents at the same time and one field in the mongus schema is designated as unique.
I am writing
Coll.insertMany(documents, function(e, d){.....})
to the console throws a duplication error and everything is correct, but you need to hide this message in the event of this error so that your eyes are not an eyesore in the server logs.
Whether already it is necessary to filter duplicates already available in a collection before data saving?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question