PaginatedList¶
- class safir.database.PaginatedList(entries, next_cursor=None, prev_cursor=None)¶
Bases:
Generic
[E
,C
]Paginated SQL results with accompanying pagination metadata.
Holds a paginated list of any Pydantic type, complete with a count and cursors. Can hold any type of entry and any type of cursor, but implicitly requires the entry type be one that is meaningfully paginated by that type of cursor.
- Parameters:
Attributes Summary
Cursor for the next batch of entries.
Cursor for the previous batch of entries.
Methods Summary
first_url
(current_url)Construct a URL to the first group of results for this query.
link_header
(current_url)Construct an RFC 8288
Link
header for a paginated result.next_url
(current_url)Construct a URL to the next group of results for this query.
prev_url
(current_url)Construct a URL to the previous group of results for this query.
Attributes Documentation
-
next_cursor:
Optional
[TypeVar
(C
, bound= PaginationCursor)] = None¶ Cursor for the next batch of entries.
-
prev_cursor:
Optional
[TypeVar
(C
, bound= PaginationCursor)] = None¶ Cursor for the previous batch of entries.
Methods Documentation
- first_url(current_url)¶
Construct a URL to the first group of results for this query.
- Parameters:
current_url (
URL
) – The starting URL of the current group of entries.- Returns:
URL to the first group of entries for this query.
- Return type:
- link_header(current_url)¶
Construct an RFC 8288
Link
header for a paginated result.- Parameters:
current_url (
URL
) – The starting URL of the current group of entries.- Returns:
Contents of an RFC 8288
Link
header.- Return type:
- next_url(current_url)¶
Construct a URL to the next group of results for this query.