Files
eventspace/backend/app/schemas/common.py
Felipe Cardoso fe2bcbd6e7 Add event counting methods and generic pagination schema
Introduce methods to count user, public, and upcoming events to enhance CRUD functionality for events. Additionally, add a `PaginatedResponse` schema to simplify and standardize paginated API responses. These updates support improved data querying and response handling.
2025-03-09 10:56:22 +01:00

22 lines
515 B
Python

from typing import Generic, List, TypeVar
from pydantic import BaseModel
T = TypeVar('T')
class PaginatedResponse(BaseModel, Generic[T]):
"""
Generic schema for paginated responses.
Attributes:
total (int): Total number of items
items (List[T]): List of items in the current page
page (int): Current page number
size (int): Number of items per page
"""
total: int
items: List[T]
page: int
size: int
class Config:
from_attributes = True