Automated Action a9210ca8ed Create manga inventory API with FastAPI and SQLite
- Implemented CRUD operations for manga, authors, publishers, and genres
- Added search and filtering functionality
- Set up SQLAlchemy ORM with SQLite database
- Configured Alembic for database migrations
- Implemented logging with Loguru
- Added comprehensive API documentation
- Set up error handling and validation
- Added ruff for linting and formatting
2025-05-30 12:29:35 +00:00

23 lines
698 B
Python

from sqlalchemy.orm import Session
from app.crud.base import CRUDBase
from app.models.manga import Author
from app.schemas.author import AuthorCreate, AuthorUpdate
class CRUDAuthor(CRUDBase[Author, AuthorCreate, AuthorUpdate]):
def get_by_name(self, db: Session, *, name: str) -> Author | None:
"""
Get an author by name.
"""
return db.query(Author).filter(Author.name == name).first()
def get_multi_with_manga(self, db: Session, *, skip: int = 0, limit: int = 100) -> list[Author]:
"""
Get multiple authors with their manga lists.
"""
return db.query(Author).offset(skip).limit(limit).all()
author = CRUDAuthor(Author)