Changelog - 2026-11-08
A repository reads every matching row, a page at a time
New FeatureIn one line. repo.findEvery() yields every row that matches a filter, one page per iteration, without loading them all and without a growing offset.
What changed
findEvery({ filter, pageSize, options })on relational repositories. It is an async iterator that yields one page (an array of up topageSizerows, 500 by default) per iteration. The last page may be shorter; an empty result yields no page.- It pages by primary key. Each page reads the rows after the last
idof the page before, in ascendingidorder. A row inserted or deleted while the loop runs does not shift the window: a smaller key is not visited, a larger one is, and no row comes twice. - It reads like
find. The default filter, the row scope and the hidden fields apply to every page,options.transactionis used for every page, and the type of a page followsfields. - Breaking out stops it. After a
break,returnor throw in the loop, no further query is made.
typescript
for await (const page of repo.findEvery({
filter: { where: { status: 'ACTIVE' } },
pageSize: 200,
})) {
await exportRows(page);
}Who is affected
- Applications that loop over
findwith a limit and an offset. No action needed;findEverycan replace the loop. - Everyone else. No action needed. The new method adds to the repository and changes nothing that exists.
Details
order,limit,skip,offsetandincludein the filter are refused with a 400: the key owns the order and the window.whereandfieldswork;idis read for the cursor even whenfieldsleaves it out, and is not returned then.pageSizeis an integer from 1 to 10 000, and at most the model'slimit.max(1000 unless the model sets it). Anything else is a 400.- The model's
idmust be a single-column primary key and not a hidden property. A composite primary key is refused with a 400. - Every refusal surfaces on the first iteration, not when
findEveryis called.
| File | Package |
|---|---|
src/relational/core/repositories/core/readable.ts | connectors |