Spaces:
Sleeping
Sleeping
Download src/models/user.py from bhaimavi353/todo-project: direct link, hf CLI and curl.
- Browser
- Download file 923 Bytes
-
https://huggingface.co/spaces/bhaimavi353/todo-project/resolve/main/src/models/user.py
- Command line
-
hf download hf://spaces/bhaimavi353/todo-project/src/models/user.py
-
curl -L -o user.py https://huggingface.co/spaces/bhaimavi353/todo-project/resolve/main/src/models/user.py
923 Bytes
| from datetime import datetime | |
| from typing import Optional, List, TYPE_CHECKING | |
| from sqlmodel import SQLModel, Field, Relationship | |
| if TYPE_CHECKING: | |
| from .task import Task | |
| from .log import Log | |
| class UserBase(SQLModel): | |
| email: str = Field(unique=True, index=True, max_length=255) | |
| class User(UserBase, table=True): | |
| __tablename__ = "users" | |
| id: Optional[int] = Field(default=None, primary_key=True) | |
| password_hash: str = Field(max_length=255) | |
| created_at: datetime = Field(default_factory=datetime.utcnow) | |
| tasks: List["Task"] = Relationship(back_populates="user") | |
| logs: List["Log"] = Relationship(back_populates="user") | |
| class UserCreate(SQLModel): | |
| email: str = Field(max_length=255) | |
| password: str = Field(min_length=8, max_length=128) | |
| class UserRead(SQLModel): | |
| id: int | |
| email: str | |
| created_at: datetime | |
| class UserLogin(SQLModel): | |
| email: str | |
| password: str | |