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})}
else{log( {err} )}
}
Is there some way to have mongodb not treat duplicates as an error?