Skip to content

Commit

Permalink
fix: update types for global prisma instance (#1321)
Browse files Browse the repository at this point in the history
* fix: update types for global prisma instance

* chore: add changeset

---------

Co-authored-by: Jing Li <[email protected]>
  • Loading branch information
JingLi1998 and jingli19984 committed Apr 1, 2023
1 parent bb22831 commit 7fcb41c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-jars-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

Update the type for global prisma instance
6 changes: 4 additions & 2 deletions cli/template/extras/src/server/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { PrismaClient } from "@prisma/client";

import { env } from "~/env.mjs";

const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined;
};

export const prisma =
globalForPrisma.prisma ||
globalForPrisma.prisma ??
new PrismaClient({
log:
env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
Expand Down

1 comment on commit 7fcb41c

@vercel
Copy link

@vercel vercel bot commented on 7fcb41c Apr 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.