Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2universalStack: sql
databasetransactionssimplicityperformance
Do not open a transaction for a single statement
A single INSERT/UPDATE/DELETE is already atomic; wrapping one statement in an explicit transaction adds overhead and noise without any consistency benefit.
PR: vinify-backend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | await db.transaction(async tx => { |
| 2 | await repo.update(values, { where: { id }, transaction: tx }); |
| 3 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | await repo.update(values, { where: { id } }); |
Explanation (EN)
Objašnjenje (HR)