Classes
PageResult
11
▼
A page of results with pagination metadata.
Constructed by ``Query.paginate()`` — not typically cr…
PageResult
11
▼
A page of results with pagination metadata.
Constructed byQuery.paginate()— not typically created directly.
Attributes
| Name | Type | Description |
|---|---|---|
items |
list[T]
|
— |
page |
int
|
— |
per_page |
int
|
— |
total |
int
|
— |
Methods
total_pages
0
int
▼
Total number of pages. Always >= 1.
property
total_pages
0
int
▼
def total_pages(self) -> int
Returns
int
has_prev
0
bool
▼
Whether a previous page exists.
property
has_prev
0
bool
▼
def has_prev(self) -> bool
Returns
bool
has_next
0
bool
▼
Whether a next page exists.
property
has_next
0
bool
▼
def has_next(self) -> bool
Returns
bool
prev_page
0
int
▼
Previous page number, clamped to 1.
property
prev_page
0
int
▼
def prev_page(self) -> int
Returns
int
next_page
0
int
▼
Next page number, clamped to total_pages.
property
next_page
0
int
▼
def next_page(self) -> int
Returns
int
offset
0
int
▼
The SQL OFFSET for this page.
property
offset
0
int
▼
def offset(self) -> int
Returns
int
page_range
1
list[int]
▼
Page numbers around the current page for navigation.
Returns up to ``2 * windo…
page_range
1
list[int]
▼
def page_range(self, window: int = 2) -> list[int]
Page numbers around the current page for navigation.
Returns up to2 * window + 1page numbers centered on
the current page, clamped to [1, total_pages].
::
PageResult(items=[], page=5, per_page=10, total=100).page_range(2)
# [3, 4, 5, 6, 7]
PageResult(items=[], page=1, per_page=10, total=100).page_range(2)
# [1, 2, 3]
Parameters
| Name | Type | Description |
|---|---|---|
window |
— |
Default:2
|
Returns
list[int]