Skip to content

Commit

Permalink
update prisma client conns
Browse files Browse the repository at this point in the history
  • Loading branch information
minhd-vu committed Feb 18, 2024
1 parent 223dfa7 commit 564a117
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();
const prismaClientSingleton = () => {
return new PrismaClient();
};

declare global {
var prisma: undefined | ReturnType<typeof prismaClientSingleton>;
}

const prisma = globalThis.prisma ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== "production") globalThis.prisma = prisma;

0 comments on commit 564a117

Please sign in to comment.