Last active
April 26, 2023 02:10
-
-
Save edanisko/a335750580c608aa75a820a2465d6eb0 to your computer and use it in GitHub Desktop.
SvelteKit - Prisma - /src/lib/server/prisma.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PrismaClient } from '@prisma/client' | |
// Avoid instantiating too many instances of Prisma in development | |
// https://www.prisma.io/docs/support/help-articles/nextjs-prisma-client-dev-practices#problem | |
let prisma: PrismaClient | |
if (process.env.NODE_ENV === 'production') { | |
prisma = new PrismaClient() | |
} else { | |
if (!global.prisma) { | |
global.prisma = new PrismaClient() | |
} | |
prisma = global.prisma | |
} | |
export { prisma } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment