Skip to content

Commit

Permalink
Update 400-nextjs-prisma-client-dev-practices.mdx (#5384)
Browse files Browse the repository at this point in the history
* Update 400-nextjs-prisma-client-dev-practices.mdx

- Add extension to the `db` file as file=./db was a bit misleading
Result: file=./db.ts

* Update content/300-guides/500-other/880-troubleshooting-orm/100-help-articles/400-nextjs-prisma-client-dev-practices.mdx

---------

Co-authored-by: Alex Ruheni <33921841+ruheni@users.noreply.github.com>
  • Loading branch information
zhandosm and ruheni authored Oct 24, 2023
1 parent 88b19da commit e920820
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In development, the command `next dev` clears Node.js cache on run. This in turn

The solution in this case is to instantiate a single instance `PrismaClient` and save it on the [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) object. Then we keep a check to only instantiate `PrismaClient` if it's not on the `globalThis` object otherwise use the same instance again if already present to prevent instantiating extra `PrismaClient` instances.

```ts file=./db
```ts file=db.ts
import { PrismaClient } from '@prisma/client'

const prismaClientSingleton = () => {
Expand Down

1 comment on commit e920820

@vercel
Copy link

@vercel vercel bot commented on e920820 Oct 24, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

docs – ./

docs-git-main-prisma.vercel.app
prisma2-docs.vercel.app
docs-prisma.vercel.app

Please sign in to comment.