Repository.FindManyOptions
The options object accepted by Repository.findMany(). See
Repositories for the full guide (filters, projection,
associations).
namespace Repository {
interface FindManyOptions extends FindOneOptions {
limit?: number;
distinct?: boolean;
maxEagerFetch?: number;
maxSubQueries?: number;
onTransformRow?: TransformRowFunction;
}
type TransformRowFunction = (
fields: FieldInfoMap,
row: object,
obj: object,
) => void;
}
FindManyOptions extends FindOneOptions, which extends FindOptions, which extends
CommandOptions plus projection/filter/params — see the
Repository.CommandOptions table for the full chain.
| Option | Type | Description |
|---|---|---|
projection | string | string[] | Fields to include/exclude. See Repositories → Projection. Passing a projection narrows the resolved type from T to PartialDTO<T>. |
filter | LogicalOperator | LogicalOperator[] | object | object[] | See Repositories → Filters. |
params | any | Named-parameter values referenced from filter via Param('name'). |
sort | string[] | Column or dotted-path names to sort by; prefix with - for descending (default ascending, + also accepted). Sorting through a to-many association is rejected (Can not sort by "...", since there's no single row to order against). |
offset | number | Row offset. |
limit | number | Max rows to return. |
distinct | boolean | Adds DISTINCT to the generated SELECT. |
maxEagerFetch | number | Caps how many related rows a to-many association's eager sub-query may return in total across the whole result set before throwing (Number of returning rows for "..." exceeds maxEagerFetch limit). Defaults to 100000. |
maxSubQueries | number | Caps how many levels deep chained to-many associations are allowed to eagerly resolve before @sqb/connect stops adding more sub-queries. Defaults to 5. |
onTransformRow | TransformRowFunction | (fields, row, obj) => void — called once per raw row during conversion, letting you inspect/mutate the raw row alongside the object being built. |
Every CommandOptions field (connection, prettyPrint, comment, optimizerHint) is also
accepted, since FindManyOptions ultimately extends it.
const customers = await repo.findMany({
filter: { active: true },
projection: ['id', 'givenName', 'country'],
sort: ['givenName'],
limit: 20,
offset: 40,
distinct: true,
});
Repository.FindOneOptions (the same shape minus limit/distinct/maxEagerFetch/
maxSubQueries/onTransformRow) backs
findOne()/findById()
instead, and does not have its own page — see the table on the
CommandOptions page for its exact shape.