-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmodels.py
More file actions
50 lines (34 loc) · 1.04 KB
/
models.py
File metadata and controls
50 lines (34 loc) · 1.04 KB
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
42
43
44
45
46
47
48
49
50
from typing import List, Optional
from pydantic import BaseModel, Field
from datetime import datetime
from bson import ObjectId
class User(BaseModel):
username: str
hashed_password: str
salt: str
profile_pic_img_src: Optional[str]
favorites: List[str] = []
disabled: bool = False
class UserInDB(User):
_id: ObjectId
date_created: datetime = Field(default_factory=datetime.utcnow)
class Message(BaseModel):
user: UserInDB
content: str = None
class MessageInDB(Message):
_id: ObjectId
timestamp: datetime = Field(default_factory=datetime.utcnow)
class Room(BaseModel):
room_name: str
members: Optional[List[UserInDB]] = []
messages: Optional[List[MessageInDB]] = []
last_pinged: datetime = Field(default_factory=datetime.utcnow)
active: bool = False
class RoomInDB(Room):
_id: ObjectId
date_created: datetime = Field(default_factory=datetime.utcnow)
class Token(BaseModel):
access_token: str
token_type: str
class TokenData(BaseModel):
username: Optional[str] = None