Download app/models/favorite.py from binhugg2/api: direct link, hf CLI and curl.
- Browser
- Download file 759 Bytes
-
https://huggingface.co/spaces/binhugg2/api/resolve/main/app/models/favorite.py
- Command line
-
hf download hf://spaces/binhugg2/api/app/models/favorite.py
-
curl -L -o favorite.py https://huggingface.co/spaces/binhugg2/api/resolve/main/app/models/favorite.py
759 Bytes
| from datetime import datetime | |
| from sqlalchemy import DateTime, Index, Integer, func | |
| from sqlalchemy.orm import Mapped, mapped_column | |
| from app.database import Base | |
| class Favorite(Base): | |
| __tablename__ = "favorite" | |
| id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) | |
| user_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="用户ID") | |
| vod_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="影片ID") | |
| created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now()) | |
| __table_args__ = ( | |
| # 唯一复合索引:防止同一用户重复收藏同一影片,同时加速查询 | |
| Index("uq_favorite_user_vod", "user_id", "vod_id", unique=True), | |
| ) | |