Metadata-Version: 2.1
Name: tortoise-pagination
Version: 1.2.2
Summary: Pagination for Tortoise-ORM on FastAPI
License: MIT
Author: Sebastien Nicolet
Author-email: snicolet95@gmail.com
Requires-Python: >=3.11,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: fastapi (>=0.104.1)
Requires-Dist: pydantic (>2.0.0)
Requires-Dist: tortoise-orm (>=0.21.0,<0.22.0)
Description-Content-Type: text/markdown

# Usage
Supposing in `myapp.schema` you have a pydantic `BaseModel` to represent your model

```python
from fastapi import Depends
from tortoise_pagination import Pagination, Page

from myapp.main import app
from myapp.models import MyModel
from myapp.schema import MySchema


@app.get('/mymodel')
async def my_view(pagination: Depends(Pagination.from_query)) -> Page[MySchema]:
    return await pagination.paginated_response(MyModel.all(), MySchema)
```

now you can request with:
```shell
curl http://localhost:8000/mymodel?offset=0&limit=20
```

returned structure:
- items list[MySchema]
- count: NonNegativeInt -> the number of entries for this queryset
  (`MyModel.all().count()`) wich the frontend will need to be able to display a pagination

