Prisma transaction client prop drilling
Transactions inside transactions, is that possible?
Anyone got experience with primsa transactions?
postgresql - Prisma: how to write transaction where results from one query are used by another query - Stack Overflow
Suppose I use prisma transaction this way:
this.prisma.$transaction(async (tx)=>{
const x1 = await this.x1Service.someTransaction(payload2,tx);
const x2 = await this.x2Service.someTransaction(x1,payload2,tx);
....
});Also suppose X1Service and X2Service pass over too many layers to reach prisma client, in order to transaction works I'd need to prop pass tx over all those layers. Is there a good way to manage it.
First Prisma transaction and it seemed simple enough. Doing the sequential method per the docs.
An operation failed because it depends on one or more records that were required but not found. Record to delete does not exist.
These records do exist, and I doubled checked the session id that it does match.
Deleting a person's account so want to make sure everything is deleted or not at all. I delete the entities related to account first because foreign key constraint. All using the sessionId to find appropriate item.
If one of the entities do not exist, like user never made products. Should this still work? I tried both ways. With products and without and still get the same error and no matter which order I do the transaction.
await prisma.$transaction([
prisma.store.delete({ where: { accountId: req.session.id }}),
prisma.product.deleteMany({ where: { accountId: req.session.id } }),
prisma.account.delete({
where: {
id: req.session.id,
},
}),
]);
