DEV Community

Aashutosh Poudel
Aashutosh Poudel

Posted on

Eagerly know if end of paginated results is reached in Prisma


Prisma doesn't return meta information like total_page or no_of_pages when returning paginated results. With information like total_page we can know beforehand if we are at the end of the page and show/hide relevant information. In prisma, this doesn't seem to be possible at the moment without adding a second query to fetch the count of results.


There's a Fetch More button at the bottom of a list. We need to enable this button only if we have more records to show. If not, we should hide this button.


This demo implementation doesn't use a second query. While fetching each page it retrieves one more record than the required page size. With this approach, the maximum number of records fetched twice is equal to the number of page requests. A more detailed explanation is attached below.


GitHub, Stackblitz

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.