Skip to content

Commit

Permalink
form singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
matmut7 committed Oct 10, 2024
1 parent 3c8f6b9 commit ca2b34a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions formulaire/src/lib/prismaClient.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
// cf https://www.prisma.io/docs/support/help-articles/nextjs-prisma-client-dev-practices

import { PrismaClient } from "@prisma/client";

const getClient = () => {
return new PrismaClient();
};
declare global {
var prismaClient: PrismaClient | undefined;
}

const client =
globalThis.prismaClient ??
new PrismaClient({
datasources: {
db: {
url: process.env.DATABASE_URL + "&connection_limit=5",
},
},
log: ["info", "warn", "error"],
});

const client = getClient();
globalThis.prismaClient = client;

export default client;

0 comments on commit ca2b34a

Please sign in to comment.