MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / generatePrismaDBFile

Function generatePrismaDBFile

src/generators/prisma/db.server.ts:1–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1export const generatePrismaDBFile = () => {
2 return [
3 'import { PrismaClient } from "@prisma/client";',
4 "",
5 "let prisma = new PrismaClient();",
6 "",
7 "declare global {",
8 " var __db__: PrismaClient | undefined;",
9 "}",
10 "",
11 "if(process.env.NODE_ENV === 'production') {",
12 " prisma = new PrismaClient();",
13 "} else {",
14 " if (!global.__db__) {",
15 " global.__db__ = new PrismaClient();",
16 " }",
17 " prisma = global.__db__;",
18 " prisma.$connect();",
19 "}",
20 "",
21 "export { prisma };",
22 ].join("\n");
23};

Callers 1

generatePrismaFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected