Skip to content

Commit

Permalink
Refactor PrismaClient initialization to enable logging
Browse files Browse the repository at this point in the history
  • Loading branch information
GithmiHashara committed Sep 13, 2024
1 parent f022b03 commit 4a959a3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/libs/prismadb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ declare global {
var prisma: PrismaClient | undefined
}


// Create a new PrismaClient instance if there isn't one already
const client = globalThis.prisma || new PrismaClient()
// Create a new PrismaClient instance with logging enabled
const client = globalThis.prisma || new PrismaClient({
log: ['query', 'info', 'warn', 'error'] // Enables Prisma logs for better debugging
})

// Assign the prisma client to the global object if it doesn't exist
if (process.env.NODE_ENV !== 'production') globalThis.prisma = client

export default client;
export default client

0 comments on commit 4a959a3

Please sign in to comment.