Concept
A transaction makes several statements succeed or fail together. Use one whenever two writes must agree, such as moving money between rows, and keep it short so it does not hold locks.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Transactions doing its job.
await sql.begin(async (tx) => {
const [from] = await tx`
UPDATE accounts SET balance = balance - ${cents}
WHERE id = ${fromId} AND balance >= ${cents} RETURNING id`;
if (!from) throw new Error("insufficient funds"); // rolls back
await tx`UPDATE accounts SET balance = balance + ${cents} WHERE id = ${toId}`;
});Doing a network call, such as charging a card, inside a database transaction. The transaction holds locks for the whole call, and a timeout leaves you unsure whether the charge happened.
Your roadmap puts these before Transactions, unless you already know them.
Once a session shows you understand Transactions, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.