-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(examples): Improve Prisma Client Initialization #9107
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 6 Skipped Deployments
|
@dpaulos6 is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Description:
This PR refactors the Prisma Client initialization to use a more robust and concise singleton pattern. The changes ensure that only one instance of
PrismaClient
is created and reused throughout the application, which improves performance and avoids potential issues with multiple instances.Changes:
prismaClientSingleton
function to create a single instance ofPrismaClient
.globalThis
to manage the global instance ofPrismaClient
, ensuring compatibility across different environments (Node.js, browser, etc.).Benefits:
PrismaClient
is used, reducing overhead.globalThis
makes the code more robust and compatible with future JavaScript standards.Testing:
PrismaClient
.I was forced to come up with a different approach as it wasn't always working in my own monorepo. Please review the changes and provide feedback if you don't like anything. Thank you!