Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save felipemotarocha/fa72e3b4e161cf98113673843d63d3e1 to your computer and use it in GitHub Desktop.
Save felipemotarocha/fa72e3b4e161cf98113673843d63d3e1 to your computer and use it in GitHub Desktop.
FSW Store - Prisma Client
import { PrismaClient } from "@prisma/client";
declare global {
var cachedPrisma: PrismaClient;
}
let prisma: PrismaClient;
if (process.env.NODE_ENV === "production") {
prisma = new PrismaClient();
} else {
if (!global.cachedPrisma) {
global.cachedPrisma = new PrismaClient();
}
prisma = global.cachedPrisma;
}
export const db = prisma;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment