GithubHelp home page GithubHelp logo

Comments (8)

marcjulian avatar marcjulian commented on June 18, 2024

Hi @JoshuaM1995 have a look at the extensions example which uses $on with an extended PrismaClient

Extended Prisma Client

export const extendedPrismaClient = new PrismaClient<
Prisma.PrismaClientOptions,
'query' | 'info' | 'warn' | 'error'
>({
log: [
{ level: 'query', emit: 'event' },
{ level: 'info', emit: 'event' },
{ level: 'warn', emit: 'event' },
{ level: 'error', emit: 'event' },
],
}).$extends({

Use $on

customPrismaService.client.$on('error', (e) => {});

from nestjs-prisma.

marcjulian avatar marcjulian commented on June 18, 2024

I tested the extensions example with the latest prisma version 4.16.1 and I am seeing the same error as you:

src/prisma.extension.ts:25:22 - error TS2339: Property '$on' does not exist on type 'DynamicClientExtensionThis<TypeMap<Args & { result: {}; model: { user: { findByEmail: () => (email: string) => Promise<GetResult<{ id: string; email: string; name: string; }, { [x: string]: () => unknown; }> & {}>; }; }; query: {}; client: {}; }>, TypeMapCb, { ...; }>'.

25 extendedPrismaClient.$on('query', (e) => {});

This might be an issue with the latest prisma version. Either $on is missing in the types or it is not available any longer for extended PrismaClients.

from nestjs-prisma.

marcjulian avatar marcjulian commented on June 18, 2024

@JoshuaM1995 I found the following issue about disallowing $on for extended clients: prisma/prisma#19552 (comment)

You can find it also in the release notes from 4.16.0

CleanShot 2023-06-26 at 10 40 54

from nestjs-prisma.

JoshuaM1995 avatar JoshuaM1995 commented on June 18, 2024

@JoshuaM1995 I found the following issue about disallowing $on for extended clients: prisma/prisma#19552 (comment)

You can find it also in the release notes from 4.16.0

CleanShot 2023-06-26 at 10 40 54

Thanks for looking into this. Are there any plans for supporting Prisma 4.16.0 any time soon? I can help contribute if possible.

If not I can try downgrading. That was the first thing I tried, but even after downgrading @prisma/client and prisma in my package.json files (I'm in a monorepo), I still see it generating the client with 4.16.0. I even tried using npx to generate it with a specific version of the cli, with no luck.

from nestjs-prisma.

JoshuaM1995 avatar JoshuaM1995 commented on June 18, 2024

Also, maybe it would be safer to lock prisma to a patch version in the package.json? @marcjulian

"@prisma/client": "~4.13.0"

from nestjs-prisma.

JoshuaM1995 avatar JoshuaM1995 commented on June 18, 2024

Update: I was able to solve this temporarily with PNPM by adding this to my package.json:

"pnpm": {
    "overrides": {
      "@prisma/client": "4.15.0",
      "prisma": "4.15.0"
    }
  }

from nestjs-prisma.

marcjulian avatar marcjulian commented on June 18, 2024

@JoshuaM1995 I have update it to the latest prisma client and added support for extension GA. Please try it out with the latest dev release:

from nestjs-prisma.

marcjulian avatar marcjulian commented on June 18, 2024

This has been released with 0.21.0

from nestjs-prisma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.