Skip to content

Commit e79ab4d

Browse files
committed
fix posts model
1 parent 0857080 commit e79ab4d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

backend/app/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class User(UserBase, table=True):
4545
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
4646
hashed_password: str
4747
items: list["Item"] = Relationship(back_populates="owner", cascade_delete=True)
48+
posts: list["Post"] = Relationship(back_populates="owner", cascade_delete=True)
4849

4950

5051
# Properties to return via API, id is always required
@@ -139,8 +140,7 @@ class PostUpdate(SQLModel):
139140
class Post(PostBase, table=True):
140141
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
141142
user_id: uuid.UUID = Field(foreign_key="user.id", nullable=False, ondelete="CASCADE")
142-
user: Optional["User"] = Relationship(back_populates="posts")
143-
143+
owner: User | None = Relationship(back_populates="posts")
144144

145145
# Properties to return via API
146146
class PostPublic(PostBase):

0 commit comments

Comments
 (0)