Hi I have following issue. I have prisma transaction but I would like to pass the prisma transaction client into a function like this:
...
prisma.$transaction(async (tx) => {
someFunction(tx)
})
...
function someFunction(tx: WHATTOTYPEHERE){
}
However I am doing it in typescript and I don't want to use type ANY. But i dont know how to type the interactive transactin prisma client... the "WHATTOTYPEHERE" type for it.
Any help is appreciated
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With