-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.py
41 lines (32 loc) · 900 Bytes
/
post.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
from typing import List
import uuid
from pydantic import BaseModel, Field
class Post(BaseModel):
id: str = Field(default_factory=lambda: str(uuid.uuid4()), alias="_id")
source_ids: List[str]
topics: List[str]
summary: str = ""
title: str = ""
media: str = ""
date: str = ""
upvotes: int = 0
downvotes: int = 0
class Config:
populate_by_name = True
json_schema_extra = {
"example": {"source_ids": ["sample"], "topics": ["sample"]}
}
class Comment(BaseModel):
id: str = Field(default_factory=lambda: str(uuid.uuid4()), alias="_id")
content: str
post_id: str
upvotes: int = 0
downvotes: int = 0
class Config:
populate_by_name = True
json_schema_extra = {
"example": {
"content": "sample",
"post_id": "sample",
}
}