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: TypeScript / Node.js
performancepaginationdatabase
Paginate at the data source, not by slicing in memory
Pass limit/offset down to the query layer instead of fetching everything and slicing afterward; in-memory slicing wastes fetch bandwidth and breaks at scale.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const all = await fetchEverything(); |
| 2 | return all.slice((page - 1) * limit, page * limit); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | return fetchPage({ from: (page - 1) * limit, size: limit }); |
Explanation (EN)
Objašnjenje (HR)