DB Pagination¶
The Pagination class is a tool for managing paginated rows from the database.
It requires the db extra to be installed:
It can be imported from fluid.db:
fluid.db.Pagination
¶
Bases: NamedTuple
create
classmethod
¶
Factory method to create a Pagination instance, decoding the cursor if provided.
If the cursor is provided, filters, limit and search are extracted from it, and the provided values for these parameters are ignored.
| PARAMETER | DESCRIPTION |
|---|---|
*order_by_fields
|
Fields to order results by
TYPE:
|
cursor
|
Encoded pagination cursor from a previous response
TYPE:
|
limit
|
Maximum number of results per page; defaults to settings.DEFAULT_PAGINATION_LIMIT
TYPE:
|
filters
|
Filters to apply to the query
TYPE:
|
search
|
Full-text search configuration
TYPE:
|
desc
|
Order results in descending order
TYPE:
|
Source code in fluid/db/pagination.py
execute
async
¶
Execute the paginated query and return the results along with the next cursor.
| PARAMETER | DESCRIPTION |
|---|---|
db
|
Database instance to execute the query on
TYPE:
|
table
|
SQLAlchemy table to query
TYPE:
|
conn
|
Optional existing connection to reuse
TYPE:
|