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 #6588

Closed
danielpaz6 opened this issue Aug 29, 2024 · 1 comment · Fixed by #6587
Closed

Not working documentation example #6588

danielpaz6 opened this issue Aug 29, 2024 · 1 comment · Fixed by #6587
Assignees

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

@SevInf SevInf transferred this issue from prisma/prisma Oct 15, 2024
@jharrell jharrell self-assigned this Dec 13, 2024
@jharrell jharrell transferred this issue from prisma/prisma-examples Jan 10, 2025
@jharrell jharrell closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2025
@jharrell jharrell reopened this Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@jharrell @danielpaz6 and others