P
Prisma4mo ago
Cuebs

How do I rollback a prisma transaction when I have 2 different prisma clients

const prismaPostgres = new PrismaPostgres();
const prismaMsSql = new PrismaMsSql();

await prismaMsSql.$transaction(async (prismaMsSql) => {
const createdKey = await prismaMsSql.keys.create({
data: data,
});

newBusinessBank.KeyId = createdKey.KeyId;
const businessBank = await prismaMsSql.businessBanks.create({
data: data,
});


});

prismaPostgres.disbursements.create({
data: data,
});
const prismaPostgres = new PrismaPostgres();
const prismaMsSql = new PrismaMsSql();

await prismaMsSql.$transaction(async (prismaMsSql) => {
const createdKey = await prismaMsSql.keys.create({
data: data,
});

newBusinessBank.KeyId = createdKey.KeyId;
const businessBank = await prismaMsSql.businessBanks.create({
data: data,
});


});

prismaPostgres.disbursements.create({
data: data,
});
My desired outcome is that the prismaMsSql and prismaPostgres work as one transaction, such that if any of them fail all of them get rolled back. Is there a way I can manually rollback and commit ?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server