
- 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
25 lines
765 B
Python
25 lines
765 B
Python
from sqlalchemy.orm import Session
|
|
|
|
from app.crud.base import CRUDBase
|
|
from app.models.manga import Publisher
|
|
from app.schemas.publisher import PublisherCreate, PublisherUpdate
|
|
|
|
|
|
class CRUDPublisher(CRUDBase[Publisher, PublisherCreate, PublisherUpdate]):
|
|
def get_by_name(self, db: Session, *, name: str) -> Publisher | None:
|
|
"""
|
|
Get a publisher by name.
|
|
"""
|
|
return db.query(Publisher).filter(Publisher.name == name).first()
|
|
|
|
def get_multi_with_manga(
|
|
self, db: Session, *, skip: int = 0, limit: int = 100
|
|
) -> list[Publisher]:
|
|
"""
|
|
Get multiple publishers with their manga lists.
|
|
"""
|
|
return db.query(Publisher).offset(skip).limit(limit).all()
|
|
|
|
|
|
publisher = CRUDPublisher(Publisher)
|