this code is also work and this is the 1st way

import { PrismaClient } from "@prisma/client";

export type PrismaTransactionalClient = Parameters<
    Parameters<PrismaClient['$transaction']>[0]
>[0];

but there is a 2nd way and this is the official way

import { Prisma } from "@prisma/client";

export type PrismaTransactionalClient = Prisma.TransactionClient;
Answer from Vishal Kumar on Stack Overflow
Discussions

Support extended Prisma Clients on `TransactionClient` type
Like @basememara says, Prisma 5 actually worsens the issue by no longer exporting ITXClientDenyList. For now I've resolved to using the very ugly · export type ExtendedPrismaServiceTransaction = Omit< ExtendedPrismaService, '$extends' | '$transaction' | '$disconnect' | '$connect' | '$on' | '$use' >; ... tech/typescriptIssue ... More on github.com
🌐 github.com
12
August 18, 2023
typescript - How does Prisma handle transactions under the hood? - Stack Overflow
How does Prisma handle transactions under the hood? In their described usage, it almost seems like Prisma has context of the calling code. const write1 = prisma.user.create() const write2 = prisma.... More on stackoverflow.com
🌐 stackoverflow.com
typescript - Using Prisma and transactions? - Stack Overflow
Prisma. Javascript to Typescript More on stackoverflow.com
🌐 stackoverflow.com
Expose the type that is passed to the interactive $transaction function
Omit< PrismaClient, '$connect' | '$disconnect' | '$on' | '$transaction' | '$use' >; I think this type should be exposed by the @prisma/client package. ... tech/typescriptIssue for tech ... More on github.com
🌐 github.com
0
January 31, 2022
🌐
DEV Community
dev.to › reyronald › dealing-with-open-database-transactions-in-prisma-3clk
Dealing with open database transactions in Prisma - DEV Community
February 23, 2025 - However, everything I mention here is also applicable to Drizzle, another ORM for JavaScript and TypeScript applications. The exact error I’m referring to is the one below: PrismaClientKnownRequestError: Transaction API error: Transaction already closed: A commit cannot be executed on an ...
🌐
Tericcabrel
blog.tericcabrel.com › database-transactions-prisma-orm
Write database transactions in Node.js with Prisma ORM
February 26, 2024 - This post shows you how to write database transactions on MySQL or PostgreSQL using the Prisma ORM in a Node.js application with TypeScript.
🌐
Wilfred
wilfred9.hashnode.dev › mastering-database-transactions-with-prisma-a-step-by-step-guide-for-nodejs-developers-using-typescript
Mastering Database Transactions with Prisma: A Step-by-Step Guide for
November 29, 2023 - By leveraging the benefits of TypeScript, Prisma ensures that your database interactions are not only efficient but also statically typed, catching potential errors at compile-time rather than runtime.
Find elsewhere
🌐
DEV Community
dev.to › this-is-learning › its-prisma-time-transactions-ji5
It's Prisma Time - Transactions - DEV Community
February 16, 2023 - #javascript #typescript #database #orm · Hello Guys 👋 Today it's time to speak about transactions. Transactions are a pillar of the database world, and they help us to make consistency in the data when we work with multiple entities. So, can Prisma not handle them?
🌐
GitHub
github.com › prisma › prisma › issues › 20738
Support extended Prisma Clients on `TransactionClient` type · Issue #20738 · prisma/prisma
August 18, 2023 - Like @basememara says, Prisma 5 actually worsens the issue by no longer exporting ITXClientDenyList. For now I've resolved to using the very ugly · export type ExtendedPrismaServiceTransaction = Omit< ExtendedPrismaService, '$extends' | '$transaction' | '$disconnect' | '$connect' | '$on' | '$use' >; ... tech/typescriptIssue for tech TypeScript.Issue for tech TypeScript.topic: client typesTypes in Prisma ClientTypes in Prisma Clienttopic: clientExtensions
Author   prisma
🌐
DEV Community
dev.to › kenfdev › cross-module-transaction-with-prisma-5d08
Cross Module Transaction with Prisma - DEV Community
June 14, 2022 - The point is that you call prisma.$transaction and you pass a callback to it with the parameter prisma. Inside the transaction, you use the prisma instance passed as the callback to use it as the transaction prisma client. It's simple and easy to use. But what if you don't want to show the prisma interface inside the transaction code?
🌐
Prisma
prisma.io › home › prisma client api › prisma client api › prisma client api
Prisma Client API | Prisma Documentation
The transaction levels can be overridden on a per-transaction level. const prisma = new PrismaClient({ transactionOptions: { isolationLevel: Prisma.TransactionIsolationLevel.Serializable, maxWait: 5000, // default: 2000 timeout: 10000, // default: 5000 }, });
🌐
Stack Overflow
stackoverflow.com › questions › 75990021 › how-does-prisma-handle-transactions-under-the-hood
typescript - How does Prisma handle transactions under the hood? - Stack Overflow
Copythis.prismaService.$transaction([ this.userService.updateStatus(user.id, 'CREDIT_DATA_RECEIVED'), this.businessService.updateFinancialData(user.business.id, { <data> // Why is this cast required and why does it work? }) as Prisma.PrismaPromise<any>, ]) typescript ·
🌐
Stack Overflow
stackoverflow.com › questions › 73179585 › using-prisma-and-transactions
typescript - Using Prisma and transactions? - Stack Overflow
await globals.prisma.$transaction(async () => { try { return await o.SaveDetails(taintedResponse); } catch (e) { throw new Error("No, not good"); } });
🌐
GitHub
github.com › prisma › prisma › issues › 11511
Expose the type that is passed to the interactive $transaction function · Issue #11511 · prisma/prisma
January 31, 2022 - Omit< PrismaClient<Prisma.PrismaClientOptions, never, Prisma.RejectOnNotFound | Prisma.RejectPerOperation | undefined>, '$connect' | '$disconnect' | '$on' | '$transaction' | '$use' >; I think this type should be exposed by the @prisma/client package. ... tech/typescriptIssue for tech TypeScript.Issue for tech TypeScript.topic: client typesTypes in Prisma ClientTypes in Prisma Clienttopic: interactiveTransactions
Author   prisma
🌐
Medium
medium.com › @moiserushanika2006 › mastering-database-rollbacks-with-prismas-transactional-finesse-9156b8319bb1
Mastering Database Rollbacks with Prisma’s Transactional Finesse | by Moise rushanika | Medium
December 23, 2023 - In this article, we’ll explore how to implement transactions with a rolling-back mechanism using Prisma, a modern database toolkit for TypeScript and Node.js, with practical code examples.
🌐
GitHub
github.com › prisma › prisma › discussions › 20924
Type of transacting prisma (e.g. tx)? · prisma/prisma · Discussion #20924
Apologies for the late reply here. I think the type you are looking for is Prisma.TransactionClient
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 28543
"Prisma cannot obtain the TypeScript type of the transaction tx." · Issue #28543 · prisma/prisma
November 18, 2025 - Bug description "When I write a transaction, Prisma does not provide type hints for tx, and following the official documentation and asking AI also cannot fix the issue." Severity 🚨 Criti...
Author   prisma
🌐
Stack Overflow
stackoverflow.com › questions › 74562722 › error-to-implement-interactive-transactions-using-prisma-orm
typescript - Error to implement Interactive transactions using Prisma ORM - Stack Overflow
# code that i write static async transfer(transaction: Transcation) { return await client.$transaction(async (ts) => { // There is a account model in my db, with balance and ID properties const sender = await ts.account.update({ data: { balance: { decrement: transaction.value } }, where: { id: transaction.debitedAccountId } }) const recipient = await ts.account.update({ data: { balance: { increment: transaction.value } }, where: { id: transaction.creditedAccountId } }) // Those will check a conditional and throw an error if true validateBalanceToTransaction(sender.balance) validateTransactionDestination(sender.id, recipient.id) return recipient; }) } I added previewFeatures to my generator on schema.prisma as the docs say
🌐
Reddit
reddit.com › r/typescript › what are the biggest gotchas/weirdnesses of prisma?
r/typescript on Reddit: What are the biggest gotchas/weirdnesses of Prisma?
November 19, 2023 -

I’m writing v2 of an app I maintain and am considering moving from Sequelize to Primsa.

From my initial investigations I really like Primsa’s typescript support and the fact it returns plain JavaScript objects rather than complex model classes. However I’ve also encountered a few weirdnesses and quirks that have set my spidey-sense tingling and given me pause about adopting it.

In particular, the fact it generates custom client code to your node_modules seems very unusual (at least I’ve never seen this before) and ripe for causing unexpected, hard to debug problems - e.g. when caching dependencies on a build server.

It also seems strangely hard to have a createdBy column on database tables without an incredible amount of boilerplate setting up inverse relationships on your User model for every single other model in your schema.

And (I think a common complaint) not being able to split up your schema file is quite annoying.

I’ve only been toying with it for a couple of days and I’ve already run into these three wrinkles, which suggests to me that if I were to carry on, I might run into more. Is that the case? Are there other rough edges I should expect to encounter? It seems to make a lot of helpful things much easier, which is great. What does it make harder?

I’m also interested in hearing about any unexpected problems you ran into using Prisma in production - things it would be hard for me to figure out/predict from first principles and are only really learned through painful experience.

Asking here rather than on a Prisma sub in the hope of getting a wide range of responses. But I may ask there as well. Thanks!

🌐
Medium
medium.com › @yisarasaq2018 › database-transaction-in-prisma-with-nestjs-and-postgres-a4bb4bbb6426
DATABASE TRANSACTION IN PRISMA WITH NESTJS AND POSTGRES | by Yisa Rasaq | Medium
January 14, 2025 - A database transaction is a sequence of operations performed as a single logical unit of work. In this context, Prisma, a modern ORM for TypeScript and JavaScript, provides a convenient method ($transaction)for handling transactions.