0.7.0
0.7.0 Summary
Added
- Automatic get_paginated endpoint
- Module
paginated
to handle utility functions - Docs updated to reflect it
Detailed
get_paginated
endpoint
-
Endpoint:
/get_paginated
-
Method:
GET
-
Description: Retrieves multiple items with pagination.
-
Query Parameters:
page
: The page number, starting from 1.itemsPerPage
: The number of items per page.
-
Example Request:
GET /yourmodel/get_paginated?page=1&itemsPerPage=3
. -
Example Return:
{
"data": [
{"id": 1, "name": "Item 1", "description": "Description of item 1"},
{"id": 2, "name": "Item 2", "description": "Description of item 2"},
{"id": 3, "name": "Item 3", "description": "Description of item 3"}
],
"total_count": 50,
"has_more": true,
"page": 1,
"items_per_page": 10
}
paginated
module
Functions:
- 1. paginated_response:
paginated_response(
crud_data: dict, page: int, items_per_page: int
) -> dict[str, Any]
Usage and Return example:
crud = FastCRUD(MyModel)
paginated_response(crud_data=crud.get_multi(MyModel), page=1, items_per_page=3)
returns
{
"data": [
{"id": 1, "name": "Item 1", "description": "Description of item 1"},
{"id": 2, "name": "Item 2", "description": "Description of item 2"},
{"id": 3, "name": "Item 3", "description": "Description of item 3"}
],
"total_count": 50,
"has_more": true,
"page": 1,
"items_per_page": 10
}
- 2. compute_offset:
compute_offset(page: int, items_per_page: int) -> int
Usage and Return example:
offset(3, 10)
returns
20
What's Changed
- Paginated by @igorbenav in #18
Full Changelog: v0.6.0...v0.7.0