Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions callback-free-itx/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ const prisma = new PrismaClient({ log: ["query"] }).$extends({
) {
const tx = prisma.$transaction((txClient) => {
setTxClient(txClient as unknown as Prisma.TransactionClient);

return txPromise.catch((e) => {
if (e === ROLLBACK) return;
throw e;
});
return txPromise;
}).catch((e) => {
if (e === ROLLBACK) return;
throw e;
});

// return a proxy TransactionClient with `$commit` and `$rollback` methods
Expand All @@ -55,6 +54,11 @@ const prisma = new PrismaClient({ log: ["query"] }).$extends({
return tx;
};
}
if (prop === "$transaction") {
return async (fn: (client: Prisma.TransactionClient) => Promise<any>) => {
return fn(target);
};
}
return target[prop as keyof typeof target];
},
}) as FlatTransactionClient;
Expand Down