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

declare global {
  namespace NodeJS {
    interface Global {}
// add prisma to the NodeJS global type
interface CustomNodeJsGlobal extends NodeJS.Global {
  prisma: PrismaClient;

// Prevent multiple instances of Prisma Client in development
declare const global: CustomNodeJsGlobal;

const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV === "development") global.prisma = prisma;

export default prisma;

Mon Feb 06 2023 05:52:36 GMT+0000 (Coordinated Universal Time)

#typescript #prismaclient

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension