const a = prisma.user.create()
throw new Error() // some error happened
const b = prisma.user.create()
prisma.$transaction([a, b])
Since an error happened, prisma.$transaction
was never called, so a
inserted into the database.
const a = prisma.user.create()
throw new Error() // some error happened
const b = prisma.user.create()
prisma.$transaction([a, b])
Since an error happened, prisma.$transaction
was never called, so a
inserted into the database.
a
will never be inserted into the database as the prisma.user.create()
command will only be called inside prisma.$transaction
so you do not need to check for that.
How about
const [a, b] = await prisma.$transaction([prisma.user.create(), prisma.user.create()])