From ea61eca9758320df02f803bdd95e80bf42a837df Mon Sep 17 00:00:00 2001 From: NGimbal Date: Tue, 22 Oct 2024 16:49:08 -0400 Subject: [PATCH] docs: adds info on extending PrismaClient type in readme --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ff358ce..000e4a5 100644 --- a/README.md +++ b/README.md @@ -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 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).