pagination#
- class starlite.datastructures.pagination.ClassicPagination#
Bases:
Generic
[T
]Container for data returned using limit/offset pagination.
- class starlite.datastructures.pagination.OffsetPagination#
Bases:
Generic
[T
]Container for data returned using limit/offset pagination.
- class starlite.datastructures.pagination.CursorPagination#
Bases:
Generic
[C
,T
]Container for data returned using cursor pagination.
- class starlite.datastructures.pagination.AbstractSyncClassicPaginator#
-
Base paginator class for sync classic pagination.
Implement this class to return paginated result sets using the classic pagination scheme.
- abstract get_total(page_size: int) int #
Return the total number of records.
- Parameters:
page_size – Maximal number of records to return.
- Returns:
An integer.
- abstract get_items(page_size: int, current_page: int) List[T] #
Return a list of items of the given size ‘page_size’ correlating with ‘current_page’.
- Parameters:
page_size – Maximal number of records to return.
current_page – The current page of results to return.
- Returns:
A list of items.
- __call__(page_size: int, current_page: int) ClassicPagination[T] #
Return a paginated result set.
- Parameters:
page_size – Maximal number of records to return.
current_page – The current page of results to return.
- Returns:
A paginated result set.
- class starlite.datastructures.pagination.AbstractAsyncClassicPaginator#
-
Base paginator class for async classic pagination.
Implement this class to return paginated result sets using the classic pagination scheme.
- abstract async get_total(page_size: int) int #
Return the total number of records.
- Parameters:
page_size – Maximal number of records to return.
- Returns:
An integer.
- abstract async get_items(page_size: int, current_page: int) List[T] #
Return a list of items of the given size ‘page_size’ correlating with ‘current_page’.
- Parameters:
page_size – Maximal number of records to return.
current_page – The current page of results to return.
- Returns:
A list of items.
- async __call__(page_size: int, current_page: int) ClassicPagination[T] #
Return a paginated result set.
- Parameters:
page_size – Maximal number of records to return.
current_page – The current page of results to return.
- Returns:
A paginated result set.
- class starlite.datastructures.pagination.AbstractSyncOffsetPaginator#
-
Base paginator class for limit / offset pagination.
Implement this class to return paginated result sets using the limit / offset pagination scheme.
- abstract get_items(limit: int, offset: int) List[T] #
Return a list of items of the given size ‘limit’ starting from position ‘offset’.
- Parameters:
limit – Maximal number of records to return.
offset – Starting position within the result set (assume index 0 as starting position).
- Returns:
A list of items.
- __call__(limit: int, offset: int) OffsetPagination[T] #
Return a paginated result set.
- Parameters:
limit – Maximal number of records to return.
offset – Starting position within the result set (assume index 0 as starting position).
- Returns:
A paginated result set.
- class starlite.datastructures.pagination.AbstractAsyncOffsetPaginator#
-
Base paginator class for limit / offset pagination.
Implement this class to return paginated result sets using the limit / offset pagination scheme.
- abstract async get_items(limit: int, offset: int) List[T] #
Return a list of items of the given size ‘limit’ starting from position ‘offset’.
- Parameters:
limit – Maximal number of records to return.
offset – Starting position within the result set (assume index 0 as starting position).
- Returns:
A list of items.
- async __call__(limit: int, offset: int) OffsetPagination[T] #
Return a paginated result set.
- Parameters:
limit – Maximal number of records to return.
offset – Starting position within the result set (assume index 0 as starting position).
- Returns:
A paginated result set.
- class starlite.datastructures.pagination.AbstractSyncCursorPaginator#
-
Base paginator class for sync cursor pagination.
Implement this class to return paginated result sets using the cursor pagination scheme.
- abstract get_items(cursor: Optional[C], results_per_page: int) Tuple[List[T], Optional[C]] #
Return a list of items of the size ‘results_per_page’ following the given cursor, if any,
- Parameters:
cursor – A unique identifier that acts as the ‘cursor’ after which results should be given.
results_per_page – A maximal number of results to return.
- Returns:
A tuple containing the result set and a new cursor that marks the last record retrieved. The new cursor can be used to ask for the ‘next_cursor’ batch of results.
- __call__(cursor: Optional[C], results_per_page: int) CursorPagination[C, T] #
Return a paginated result set given an optional cursor (unique ID) and a maximal number of results to return.
- Parameters:
cursor – A unique identifier that acts as the ‘cursor’ after which results should be given.
results_per_page – A maximal number of results to return.
- Returns:
A paginated result set.
- class starlite.datastructures.pagination.AbstractAsyncCursorPaginator#
-
Base paginator class for async cursor pagination.
Implement this class to return paginated result sets using the cursor pagination scheme.
- abstract async get_items(cursor: Optional[C], results_per_page: int) Tuple[List[T], Optional[C]] #
Return a list of items of the size ‘results_per_page’ following the given cursor, if any,
- Parameters:
cursor – A unique identifier that acts as the ‘cursor’ after which results should be given.
results_per_page – A maximal number of results to return.
- Returns:
A tuple containing the result set and a new cursor that marks the last record retrieved. The new cursor can be used to ask for the ‘next_cursor’ batch of results.
- async __call__(cursor: Optional[C], results_per_page: int) CursorPagination[C, T] #
Return a paginated result set given an optional cursor (unique ID) and a maximal number of results to return.
- Parameters:
cursor – A unique identifier that acts as the ‘cursor’ after which results should be given.
results_per_page – A maximal number of results to return.
- Returns:
A paginated result set.