-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Callback-free interactive transactions #12458
Copy link
Copy link
Open
Labels
kind/featureA request for a new feature.A request for a new feature.tech/typescriptIssue for tech TypeScript.Issue for tech TypeScript.topic: $transactionRelated to .$transaction(...) Client APIRelated to .$transaction(...) Client APItopic: extend-clientExtending the Prisma ClientExtending the Prisma Clienttopic: interactiveTransactionstopic: rollbacktopic: transaction
Description
Problem
Some users are asking for a less restricted way for opening an interactive transaction. Instead of having a callback for the transaction, there would be manual calls to $begin, $commit, and $rollback.
Suggested solution
Example of a use-case
describe('some test', () => {
let trx: Transaction;
beforeEach(async () => {
trx = await prisma.$begin();
jest.mock('./prisma', () => trx);
});
afterEach(async () => {
await trx.$rollback();
});
it('.....', () => {
// ....
});
});Alternatives
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/featureA request for a new feature.A request for a new feature.tech/typescriptIssue for tech TypeScript.Issue for tech TypeScript.topic: $transactionRelated to .$transaction(...) Client APIRelated to .$transaction(...) Client APItopic: extend-clientExtending the Prisma ClientExtending the Prisma Clienttopic: interactiveTransactionstopic: rollbacktopic: transaction