Michael Roberts
09/12/2022, 11:54 AMconst transactionId = prisma.trasaction()
prisma.user.create()
try {
prisma.session.create()
} catch {
prisma.rollback(transactionId)
}
Austin
09/13/2022, 7:16 PMinteractiveTransactions
(docs) which can accomplish a similar thing.
prisma.$transaction(async (tx) => {
await prisma.session.create()
// if an error is thrown, the transaction is rolled back
})
Be aware, this feature is still in preview.Vladi Stevanovic
Michael Roberts
09/22/2022, 12:58 PMMichael Roberts
09/22/2022, 12:58 PMAustin
09/22/2022, 1:42 PM$transaction
callback will trigger a rollback.
From the docs:
If the application encounters an error along the way, the async function will throw an exception and automatically rollback the transaction.