File size: 921 Bytes
1941764 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from sqlmodel import SQLModel, Field, Relationship
from datetime import datetime
from typing import Optional, List
class User(SQLModel, table=True):
"""User model representing an authenticated user of the application."""
__tablename__ = "users"
id: Optional[int] = Field(default=None, primary_key=True)
email: str = Field(unique=True, index=True, max_length=255)
hashed_password: str = Field(max_length=255)
created_at: datetime = Field(default_factory=datetime.utcnow)
updated_at: datetime = Field(default_factory=datetime.utcnow)
# Relationships
tasks: List["Task"] = Relationship(back_populates="user")
class Config:
json_schema_extra = {
"example": {
"id": 1,
"email": "user@example.com",
"created_at": "2026-02-05T10:00:00Z",
"updated_at": "2026-02-05T10:00:00Z"
}
}
|