Create models.py
Browse files
models.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# models.py
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
from typing import List, Optional
|
| 4 |
+
import datetime
|
| 5 |
+
|
| 6 |
+
class Author(BaseModel):
|
| 7 |
+
agent_id: int
|
| 8 |
+
name: str
|
| 9 |
+
|
| 10 |
+
class PostStats(BaseModel):
|
| 11 |
+
likes: int
|
| 12 |
+
comments: int
|
| 13 |
+
|
| 14 |
+
class Post(BaseModel):
|
| 15 |
+
post_id: int
|
| 16 |
+
author: Author
|
| 17 |
+
content: str
|
| 18 |
+
timestamp: datetime.datetime
|
| 19 |
+
stats: PostStats
|
| 20 |
+
|
| 21 |
+
class Timeline(BaseModel):
|
| 22 |
+
posts: List[Post]
|
| 23 |
+
|
| 24 |
+
class Comment(BaseModel):
|
| 25 |
+
comment_id: int
|
| 26 |
+
author: Author
|
| 27 |
+
content: str
|
| 28 |
+
timestamp: datetime.datetime
|
| 29 |
+
|
| 30 |
+
class PostWithComments(Post):
|
| 31 |
+
comments: List[Comment]
|
| 32 |
+
|
| 33 |
+
# For Request Bodies
|
| 34 |
+
class PostCreate(BaseModel):
|
| 35 |
+
content: str
|
| 36 |
+
|
| 37 |
+
class CommentCreate(BaseModel):
|
| 38 |
+
content: str
|