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 ruleP1universalStack: universal
performancedatabaseasync
Reuse already-fetched data instead of issuing a redundant query
If a value was already loaded (or can join the existing parallel batch), do not fire a separate sequential query for it; reuse the data or add it to the parallel fetch.
PR: hegnar-user-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | const [holdings, flag] = await Promise.all([getHoldingsWithTxFlags(id), canAdd(id)]); |
| 2 | const isPortfolio = await hasAnyTransaction(id); // extra sequential query for data we already have |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const [holdings, flag, hasTx] = await Promise.all([ |
| 2 | getHoldingsWithTxFlags(id), canAdd(id), hasAnyTransaction(id), |
| 3 | ]); |
| 4 | const isPortfolio = holdings.some((h) => h.hasTransactions) || hasTx; |
Explanation (EN)
Objašnjenje (HR)