PrismaP
Prisma14mo ago
5 replies
rwieruch

Transactions across Files

I have the following two calls, one a direct Prisma call and the other one a Service call which does multiple inner Prisma calls.

await prisma.comment.delete({
  where: { id },
});

await ticketService.disconnectReferencedTicketsViaComment(comment);


I found this discussion related to it: https://github.com/prisma/prisma/issues/12975 Is there no way to implement this as a transaction? At least it would be useful to provide a workaround as an example like mentioned over here: https://github.com/prisma/prisma/issues/12975#issuecomment-1426915067

So my guess is that we should use interactive transactions and pass the tx to the service, correct?

https://www.prisma.io/docs/orm/prisma-client/queries/transactions#example
GitHub
Discussed in #12974 Originally posted by jaequery April 23, 2022 Coming from TypeORM, I am surprised to see that Prisma does not have any way to perform transactions in a similar way TypeORM does. ...
Does Prisma offer Transactions across multiple files? · Issue #1297...
This page explains the transactions API of Prisma Client.
Transactions and batch queries (Reference) | Prisma Documentation
Was this page helpful?