Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably only silently return if 'silent' is true

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes true, I have handled that case in else if statement.

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