File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1+ // lib/prisma.ts
12import { PrismaClient } from '@prisma/client'
23import { withAccelerate } from '@prisma/extension-accelerate'
34
5+ // Create a singleton instance of PrismaClient extended with accelerate and logging.
46const prismaClientSingleton = ( ) => {
5- return new PrismaClient ( ) . $extends ( withAccelerate ( ) )
7+ return new PrismaClient ( {
8+ log : [ 'query' ] ,
9+ } ) . $extends ( withAccelerate ( ) )
610}
711
12+ // Use a global variable to persist the Prisma Client across hot reloads in development.
813declare const globalThis : {
914 prismaGlobal : ReturnType < typeof prismaClientSingleton >
1015} & typeof global
1116
1217const prisma = globalThis . prismaGlobal ?? prismaClientSingleton ( )
1318
14- export default prisma
19+ if ( process . env . NODE_ENV !== 'production' ) {
20+ globalThis . prismaGlobal = prisma
21+ }
1522
16- if ( process . env . NODE_ENV !== 'production' ) globalThis . prismaGlobal = prisma
23+ export default prisma
You can’t perform that action at this time.
0 commit comments