Paginate/Page

paginate and page Method Documentation

Here’s how the documentation for both paginate and page methods would look like, using tabs to display TypeScript examples, generated query parameters, and their corresponding query strings:

Note:

After finishing building your query attach .build() to generate it.


Method Signature

paginate(value: number, page?:number): this;

page(value: number): this;
  • paginate value: The number of records to return per page.
  • paginate page: The page number you want to return.
  • page value: The page number you want to return.

Examples

// Using paginate with perPage only
query.paginate(10);

// Using paginate with perPage and page number
queryWithPage.paginate(10, 2);

// Using page to set the page number
queryPage.page(3);

Methods

1. paginate(perPage: number, page?: number)

The paginate method sets the number of items per page (perPage) and optionally the current page (page).

  • Parameters:

    • perPage: The number of items per page.
    • page: (Optional) The page number to fetch.
  • Query Parameter:

    • paginate: Number of items per page.
    • page: (Optional) Page number if provided.

2. page(page: number)

The page method is used to set the page number when pagination has already been applied. It sets the current page number for the query.

  • Parameters:

    • page: The page number to fetch.
  • Query Parameter:

    • page: The page number.

Usage Cases Table

FormatExampleQuery String
Paginate with perPagequery.paginate(10)?paginate=10
Paginate with perPage & pagequery.paginate(10, 2)?paginate=10&page=2
Set page numberquery.page(3)?page=3