'How to set max results for Pagination in TypeORM
I want to use pagination on a large dataset. Until now, the following has been working well.
await myRepository.findAndCount({
where: whereClauses,
skip: currentPage * pageSize,
take: pageSize
)};
My problem is in the following situation:
Say I have pageSize=1000 and the result set is 300,000 results. The findAndCount method is still taking a long time to complete. I would like to set something like a maxResults where the highest possible number of pages would be maxResults/pageSize in order to reduce the processing time.
In the case above, with a pageSize of 1,000 and total results of 300k, the max results would prevent me from ever counting the full 300k dataset, instead cutting it off at 100k.
I would still like to use the findAndCount functionality so that on my UI, I can keep showing users how many pages of data exist (i.e. "You are on Page 3 of 100") but throw up a warning if they hit the max number of results.
Is this possible in typeORM?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
