Skip to content

Commit

Permalink
feat(mongoose): set debug to troubleshoot queries
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneRifle committed Sep 11, 2024
1 parent cf52953 commit 41010e2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions replacements/src/app/loaders/mongoose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ export default async (): Promise<Connection> => {
await connect()
}

mongoose.set('debug', (collectionName, method, query, doc) => {
logger.info({
message: `${collectionName}.${method}`,
meta: {
action: 'mongoose',
query,
doc,
},
})
})

mongoose.connection.on('error', (err) => {
// No need to reconnect here since mongo config has auto reconnect, we log.
logger.error({
Expand Down

0 comments on commit 41010e2

Please sign in to comment.