Skip to content

Commit

Permalink
docs: adds info on extending PrismaClient type in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
NGimbal committed Oct 22, 2024
1 parent 8380200 commit ea61eca
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,21 @@ and don't require a preview feature flag.
```ts
import { PrismaClient } from '@prisma/client'
import { fieldEncryptionExtension } from 'prisma-field-encryption'
import { type PrismaClientExtends } from '@prisma/client/extension'
import type * as runtime from '@prisma/client/runtime/library'

// Define the extended client type using Prisma's extension type system
type ExtendedClient = PrismaClient &
PrismaClientExtends<runtime.Types.Extensions.DefaultArgs>

const globalClient = new PrismaClient()

export const client = globalClient.$extends(
// This is a function, don't forget to call it:
fieldEncryptionExtension()
)
) as ExtendedClient

export type { ExtendedClient as PrismaClient }
```

Read more about how to use [Prisma client extensions](https://www.prisma.io/docs/concepts/components/prisma-client/client-extensions).
Expand Down

0 comments on commit ea61eca

Please sign in to comment.