Pagination
| CLASS | DESCRIPTION |
|---|---|
PaginationData |
Metadata describing the state of a paginated query. |
PaginationResponse |
Paginated response container including both pagination metadata and result |
| FUNCTION | DESCRIPTION |
|---|---|
get_paginated_response |
Execute a paginated query and return a structured response. |
get_pagination_data |
Apply pagination to a SQLAlchemy statement and compute pagination metadata. |
Classes¶
PaginationData
pydantic-model
¶
PaginationResponse
pydantic-model
¶
Functions:¶
get_paginated_response(*, stm, stm_count, pagination, db)
async
¶
Execute a paginated query and return a structured response.
This only applies to SelectOfScalar[T] statements, i.e. applies to
select(X) but not to select(X, Y).
| PARAMETER | DESCRIPTION |
|---|---|
|
TYPE:
|
|
TYPE:
|
|
TYPE:
|
|
TYPE:
|
Source code in fractal_server/app/routes/pagination.py
get_pagination_data(*, stm, stm_count, pagination, db)
async
¶
Apply pagination to a SQLAlchemy statement and compute pagination metadata.
This function executes a separate count query to determine the total number of available items, then applies the appropriate OFFSET and LIMIT to the provided statement based on the requested pagination parameters.
| PARAMETER | DESCRIPTION |
|---|---|
|
TYPE:
|
|
TYPE:
|
|
TYPE:
|
|
TYPE:
|
Returns:
A tuple containing:
- The modified SQLAlchemy statement with proper OFFSET and LIMIT.
- A PaginationData instance with:
* current_page: the requested page number;
* page_size: the effective page size;
* total_count: the total number of available items.