PaginatedList

class safir.database.PaginatedList(entries, next_cursor, prev_cursor)

Bases: Generic[E, C]

Paginated SQL results with accompanying pagination metadata.

Holds a paginated list of any Pydantic type with pagination 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:

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.

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:

str

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:

str

next_url(current_url)

Construct a URL to the next group of results for this query.

Parameters:

current_url (URL) – The starting URL of the current group of entries.

Returns:

URL to the next group of entries for this query or None if there are no further entries.

Return type:

str or None

prev_url(current_url)

Construct a URL to the previous group of results for this query.

Parameters:

current_url (URL) – The starting URL of the current group of entries.

Returns:

URL to the previous group of entries for this query or None if there are no further entries.

Return type:

str or None