Skip to content

Commit

Permalink
fix: hash for log model should be unique
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Feb 27, 2025
1 parent a0d4f55 commit 7403577
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ const Logs = new mongoose.Schema({
hash: {
type: String,
index: true,
required: true
required: true,
unique: true
},
user: {
type: mongoose.Schema.ObjectId,
Expand Down
2 changes: 2 additions & 0 deletions helpers/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ async function hook(err, message, meta) {
process.env.NODE_ENV === 'test'
)
return;
// unique hash (already exists)
if (err.code === 11000) return;
//
// NOTE: this allows us to log mongodb timeout issues (e.g. due to slow queries)
//
Expand Down

0 comments on commit 7403577

Please sign in to comment.