Don't send an error for duplicate unique indexes? [duplicate]
0 This question already has an answer here: How to Ignore Duplicate Key Errors Safely Using insert_many 1 answer MongoDB Bulk Insert Ignore Duplicate 1 answer I have a unique index, because I want mongoDB to ignore any duplicates: dbo.collection("sold").createIndex( "myId": 1 , unique: true ) However, mongodb treats this as an error, meaning I have to create special error handlign in my application code: catch(err) if(err.code === 11000)log(completed: err.result.nInserted, duplicates: err.result.result.writeErrors.length) elselog( err ) Is there some way to have mongodb not treat duplicates as an error? mongodb share | improve this question asked Nov 11 '18 at 22:49 Himmators 5,570 26 85 173 marked as duplicate by Neil Lunn mongodb Users with the mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed. StackExchange.ready(function() if (StackExchange.options...