Skip to content

Commit

Permalink
Fixed uncaught dup key with caracal @ develop camicroscope#140
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhishekPanta8 committed Mar 17, 2023
1 parent 945e448 commit 21b30c5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion service/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ class Mongo {
const res = await collection.insertMany(data);
return res;
} catch (e) {
if (silent) {
if (e.code === 11000) {
console.warn(`Duplicate key error in collection '${collectionName}': ${e.keyValue}`);
return;
} else if (silent) {
console.warn('insert into ' + collectionName + ' did not occur, continuing because silent set')
} else {
console.error(e);
Expand Down

0 comments on commit 21b30c5

Please sign in to comment.