Cuebs
Cuebs
PPrisma
Created by Cuebs on 8/27/2024 in #help-and-questions
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 ?
2 replies