Spaces:
Runtime error
Runtime error
Download models.py from MaheenGhouri/fullstack_todo_app: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/MaheenGhouri/fullstack_todo_app/resolve/main/models.py
- Command line
-
hf download hf://spaces/MaheenGhouri/fullstack_todo_app/models.py
-
curl -L -o models.py https://huggingface.co/spaces/MaheenGhouri/fullstack_todo_app/resolve/main/models.py
1.32 kB
| from sqlmodel import SQLModel, Field, Relationship | |
| from datetime import datetime | |
| from typing import Optional | |
| import uuid | |
| class User(SQLModel, table=True): | |
| __tablename__ = "users" | |
| id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True) | |
| email: str = Field(unique=True, index=True) | |
| password_hash: str | |
| name: Optional[str] = None | |
| created_at: datetime = Field(default_factory=datetime.utcnow) | |
| updated_at: datetime = Field(default_factory=datetime.utcnow) | |
| # Relationship to tasks | |
| tasks: list["Task"] = Relationship(back_populates="user") | |
| class Task(SQLModel, table=True): | |
| __tablename__ = "tasks" | |
| id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True) | |
| title: str | |
| description: Optional[str] = None | |
| status: str = Field(default="todo", index=True) # "todo", "done" | |
| priority: str = Field(default="medium", index=True) # "low", "medium", "high" | |
| due_date: Optional[datetime] = Field(default=None, index=True) | |
| created_at: datetime = Field(default_factory=datetime.utcnow, index=True) | |
| updated_at: datetime = Field(default_factory=datetime.utcnow) | |
| # Foreign key to user | |
| user_id: uuid.UUID = Field(foreign_key="users.id", ondelete="CASCADE") | |
| # Relationship to user | |
| user: User = Relationship(back_populates="tasks") |