Spaces:
Sleeping
Sleeping
Download src/journaling/models.py from shrisdiablo/dev-yuvabe-app-api: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/shrisdiablo/dev-yuvabe-app-api/resolve/main/src/journaling/models.py
- Command line
-
hf download hf://spaces/shrisdiablo/dev-yuvabe-app-api/src/journaling/models.py
-
curl -L -o models.py https://huggingface.co/spaces/shrisdiablo/dev-yuvabe-app-api/resolve/main/src/journaling/models.py
1.12 kB
| import uuid | |
| from datetime import date, datetime | |
| from typing import Optional | |
| from sqlalchemy.dialects.postgresql import UUID | |
| from sqlalchemy import Column, ForeignKey, UniqueConstraint | |
| from sqlmodel import SQLModel, Field, Relationship | |
| class JournalEntry(SQLModel, table=True): | |
| __tablename__ = "journal_entries" | |
| __table_args__ = ( | |
| UniqueConstraint("user_id", "journal_date", name="unique_user_date_journal"), | |
| ) | |
| id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True) | |
| user_id: uuid.UUID = Field( | |
| sa_column=Column( | |
| UUID(as_uuid=True), | |
| ForeignKey("users.id", ondelete="CASCADE"), | |
| nullable=False, | |
| ) | |
| ) | |
| title: str = Field(nullable=False) | |
| content: str = Field(nullable=False) | |
| journal_date: date = Field(nullable=False) | |
| created_at: datetime = Field(default_factory=datetime.now) | |
| updated_at: datetime = Field( | |
| default_factory=datetime.now, | |
| sa_column_kwargs={"onupdate": datetime.now}, | |
| nullable=False, | |
| ) | |
| user: Optional["Users"] = Relationship(back_populates="journal_entries") | |