Pagination

Pydantic model

pydantic model iperon.contrib.pagination.Pagination

Show JSON schema
{
   "title": "Pagination",
   "type": "object",
   "properties": {
      "current_page": {
         "title": "Current Page",
         "default": 1,
         "type": "integer"
      },
      "previous_page": {
         "title": "Previous Page",
         "type": "integer"
      },
      "next_page": {
         "title": "Next Page",
         "type": "integer"
      },
      "total_page": {
         "title": "Total Page",
         "type": "integer"
      },
      "total_counter": {
         "title": "Total Counter",
         "type": "integer"
      },
      "limit": {
         "title": "Limit",
         "type": "integer"
      }
   }
}

Fields
field current_page: int = 1
field limit: int = None
field next_page: Optional[int] = None
field previous_page: Optional[int] = None
field total_counter: int = None
field total_page: int = None
classmethod pagination(current_page: int, total_counter: int, limit: int = 50) iperon.contrib.pagination.Pagination

Forming a paging class

Parameters
  • current_page (int) – Current page

  • total_counter (int) – Total pages

  • limit (int) – Limit of records per page, default 50 records

Returns

Return Pagination object

Return type

Pagination

Function generates limit, offset for SQL

class iperon.contrib.pagination.offset_limit(current_page: int, limit: int = 50)

Generates limit, offset for SQL

Parameters
  • current_page – Current page

  • limit (int) – Limit per page, default 50 pages

Returns

Returns a list of tuples where the first element is offset, the second is limit

Return type

tuple