CODY
CODY
Explore posts from servers
DTDrizzle Team
Created by CODY on 12/23/2023 in #help
Can I .prepare() a transaction?
Surprisingly I can call prepare inside transaction callback but it doesn't make sense to me since we usually using prepare() as a variable out of block scope.
await db.transaction(async (tx) => {
const q1 = tx.update(...).set(...).where(...).prepare();
const q2 = tx.insert(...).values(...).prepare();

await q1.execute();
await q2.execute();
});
await db.transaction(async (tx) => {
const q1 = tx.update(...).set(...).where(...).prepare();
const q2 = tx.insert(...).values(...).prepare();

await q1.execute();
await q2.execute();
});
5 replies