Last active
November 6, 2025 19:29
-
-
Save ricardocuellar/aa4050490bb39962686f019bb0786cc1 to your computer and use it in GitHub Desktop.
FastAPI - Sección 13 - Category - Repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import annotations | |
| from typing import Iterable, Sequence | |
| from collections.abc import Iterable as IterableABC | |
| from sqlalchemy import select, func | |
| from sqlalchemy.exc import IntegrityError | |
| from sqlalchemy.orm import Session | |
| from app.models.category import CategoryORM | |
| class CategoryRepository: | |
| def __init__(self, db: Session) -> None: | |
| pass | |
| def list_many(self, *, skip: int = 0, limit: int = 50) -> Sequence[CategoryORM]: | |
| pass | |
| def list_with_total(self, *, page: int = 1, per_page: int = 50) -> tuple[int, list[CategoryORM]]: | |
| pass | |
| def get(self, category_id: int) -> CategoryORM | None: | |
| pass | |
| def get_by_slug(self, slug: str) -> CategoryORM | None: | |
| pass | |
| def create(self, *, name: str, slug: str) -> CategoryORM: | |
| pass | |
| def update(self, category: CategoryORM, updates: dict) -> CategoryORM: | |
| pass | |
| def delete(self, category: CategoryORM) -> None: | |
| pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment