Skip to content
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

Not working documentation example #6840

Open
danielpaz6 opened this issue Aug 29, 2024 · 1 comment
Open

Not working documentation example #6840

danielpaz6 opened this issue Aug 29, 2024 · 1 comment
Assignees
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. documentation kind/bug A reported bug.

Comments

@danielpaz6
Copy link

danielpaz6 commented Aug 29, 2024

In client extensions there's a transaction example:

const prisma = new PrismaClient().$extends({
  query: {
    user: {
      // Get the input `args` and a callback to `query`
      async findFirst({ args, query, operation }) {
        const [result] = await prisma.$transaction([query(args)]) // wrap the query in a batch transaction, and destructure the result to return an array
        return result // return the first result found in the array
      },
    },
  },
})

Reference: https://www.prisma.io/docs/orm/prisma-client/client-extensions/query#wrap-a-query-into-a-batch-transaction

But the inner await prisma.$transaction is not defined because we are just now defining the prisma variable (const prisma = new PrismaClient().$extends({ ...)

So this example is broken

@apolanc apolanc added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. labels Aug 29, 2024
@SevInf SevInf transferred this issue from prisma/prisma Oct 15, 2024
@jharrell jharrell added the documentation label Dec 13, 2024 — with Linear
@jharrell jharrell self-assigned this Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. documentation kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

4 participants
@jharrell @apolanc @danielpaz6 and others