You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
now (v5.6.0),
In an interactive transaction, we must throw an error to command a rollback.
This has the following drawback:
non type-safe
make code less predicatable
It requires incidental error handling code.
=> potential risk
Suggested solution
rollback when inner function return Prisma.Rollback instance.
constprisma=newPrismaClien();constresponse: Prisma.users|"NOT_FOUND_USER"|"UNVERIFIED_USER"=awaitprisma.$transaction(async(tx)=>{constuser: Prisma.users|null=awaittx.users.findFirst({where: {id: 1}});Prisma.Rollback();// it is just instance, so this line does nothing.if(user===null)returnPrisma.Rollback("NOT_FOUND_USER");if(!user.verified)returnPrisma.Rollback("UNVERIFIED_USER");// ... some transaction code...returnuser;});
The text was updated successfully, but these errors were encountered:
rojiwon123
changed the title
Rollback Transaction Without throwing Error.
[Feature Request] Rollback Transaction Without throwing Error.
Nov 20, 2023
rojiwon123
changed the title
[Feature Request] Rollback Transaction Without throwing Error.
[Feature Request] a new way for rollback Transaction Without throwing Error.
Nov 20, 2023
rojiwon123
changed the title
[Feature Request] a new way for rollback Transaction Without throwing Error.
[Feature Request] Rollback Transaction Without throwing Error.
Nov 20, 2023
rojiwon123
changed the title
[Feature Request] Rollback Transaction Without throwing Error.
[Feature Request] Rollback Interactive Transaction Without throwing Error.
Nov 20, 2023
Hi @industriously.
There is already a feature request for this functionality in #15211. I am going to close this as a duplicate, if you have any input, please, comment on the other issue.
Problem
now (v5.6.0),
In an interactive transaction, we must throw an error to command a rollback.
This has the following drawback:
=>
potential risk
Suggested solution
Prisma.Rollback
instance.Alternatives
endHandler
.Additional context
#15211
#8664 (comment)
The text was updated successfully, but these errors were encountered: