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 ruleP2project specificStack: TypeScript
performancesimplicityqueries
Prefer the simpler query method when you don't need its heavier variant
Use the lightweight query call (asArray) over the iterating/paginating one (all) when limits make the difference moot; the iterating variant adds unnecessary count checks and extra round-trips.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const articles = await repo.byTagId(id).limit(10).all(); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const articles = await repo.byTagId(id).limit(10).asArray(); |
Explanation (EN)
Objašnjenje (HR)