MCPcopy
hub / github.com/ormar-orm/ormar / paginate

Method paginate

ormar/queryset/queryset.py:941–958  ·  view source on GitHub ↗

You can paginate the result which is a combination of offset and limit clauses. Limit is set to page size and offset is set to (page-1) * page_size. :param page_size: numbers of items per page :type page_size: int :param page: page number :type page:

(self, page: int, page_size: int = 20)

Source from the content-addressed store, hash-verified

939 return await executor.execute(expr)
940
941 def paginate(self, page: int, page_size: int = 20) -> "QuerySet[T]":
942 """
943 You can paginate the result which is a combination of offset and limit clauses.
944 Limit is set to page size and offset is set to (page-1) * page_size.
945
946 :param page_size: numbers of items per page
947 :type page_size: int
948 :param page: page number
949 :type page: int
950 :return: QuerySet
951 :rtype: QuerySet
952 """
953 if page < 1 or page_size < 1:
954 raise QueryDefinitionError("Page size and page have to be greater than 0.")
955
956 limit_count = page_size
957 query_offset = (page - 1) * page_size
958 return self.rebuild_self(limit_count=limit_count, offset=query_offset)
959
960 def limit(
961 self, limit_count: int, limit_raw_sql: Optional[bool] = None

Callers 5

test_is_nullFunction · 0.45
test_pagination_errorsFunction · 0.45
test_proxy_paginationFunction · 0.45
paginationFunction · 0.45

Calls 2

rebuild_selfMethod · 0.95

Tested by 4

test_is_nullFunction · 0.36
test_pagination_errorsFunction · 0.36
test_proxy_paginationFunction · 0.36