Implement custom `totalCount` step from connection step
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 625
- Avg merge
- 5h 23m
- Merged PRs (30d)
- 24
Description
### Summary
[discord context](https://discord.com/channels/489127045289476126/1346789719954161756/1346915146551005306)
How to create custom implementation of `totalCount`, where I want to cap the number of rows, to avoid scanning very large tables. What I want to do, is to clone the parent connection with the filters client have sent, but remove the pagination from them, and instead run `setFirst` according to my cap params, and run count on the aggregate. Example
```ts
const $clone = $connection.cloneSubplanWithPagination('normal');
$clone.setFirst(constant(cap)); // for example 100000 rows
return connection($clone)
.cloneSubplanWithoutPagination('aggregate')
.singleAsRecord()
.select(sql`count(*)`, TYPES.bigint, false) as any;
```
### Additional context
Contributor guide
Assessment
This issue has not been assessed yet.