
- Add proper model relationships for better querying - Implement character model and endpoints for managing anime characters - Add advanced filtering options (year, score range, source, studio, etc.) - Add statistics endpoint for analyzing anime collection - Include pagination metadata for easier navigation - Create Alembic migration for the new character model - Update README with new features and documentation
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, Float, Text, Date
|
|
from sqlalchemy.orm import relationship
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class Anime(Base):
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String(255), index=True, nullable=False)
|
|
alternative_titles = Column(String(500), nullable=True)
|
|
synopsis = Column(Text, nullable=True)
|
|
episodes = Column(Integer, nullable=True)
|
|
status = Column(String(50), nullable=True) # airing, finished, upcoming
|
|
aired_from = Column(Date, nullable=True)
|
|
aired_to = Column(Date, nullable=True)
|
|
duration = Column(String(50), nullable=True) # per episode (e.g., "24 min per ep")
|
|
rating = Column(String(50), nullable=True) # PG-13, R, etc.
|
|
score = Column(Float, nullable=True)
|
|
ranked = Column(Integer, nullable=True)
|
|
popularity = Column(Integer, nullable=True)
|
|
studio = Column(String(100), nullable=True)
|
|
source = Column(String(50), nullable=True) # manga, light novel, etc.
|
|
image_url = Column(String(255), nullable=True)
|
|
|
|
# Relationships
|
|
characters = relationship("Character", back_populates="anime", cascade="all, delete-orphan") |