Download src/models/task.py from BilalCode/TaskFlow: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/spaces/BilalCode/TaskFlow/resolve/main/src/models/task.py
- Command line
-
hf download hf://spaces/BilalCode/TaskFlow/src/models/task.py
-
curl -L -o task.py https://huggingface.co/spaces/BilalCode/TaskFlow/resolve/main/src/models/task.py
811 Bytes
| from sqlmodel import Field, SQLModel, Relationship | |
| from typing import Optional, TYPE_CHECKING | |
| from datetime import datetime | |
| if TYPE_CHECKING: | |
| from .user import User | |
| class Task(SQLModel, table=True): | |
| """Task model representing a todo item belonging to a specific user.""" | |
| __tablename__ = "tasks" | |
| id: Optional[int] = Field(default=None, primary_key=True) | |
| title: str = Field(max_length=200, min_length=1) | |
| description: Optional[str] = Field(default=None, max_length=2000) | |
| completed: bool = Field(default=False) | |
| user_id: int = Field(foreign_key="users.id", index=True) | |
| created_at: datetime = Field(default_factory=datetime.utcnow) | |
| updated_at: datetime = Field(default_factory=datetime.utcnow) | |
| # Relationships | |
| owner: "User" = Relationship(back_populates="tasks") | |