-
Notifications
You must be signed in to change notification settings - Fork 0
/
schemas.py
55 lines (41 loc) · 932 Bytes
/
schemas.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from pydantic import BaseModel, EmailStr
from typing import List, Optional
from datetime import datetime
class VoteBase(BaseModel):
video_id: int
class VoteCreate(VoteBase):
pass
class Vote(VoteBase):
id: int
user_id: int
created_at: datetime
class Config:
orm_mode = True
class VideoBase(BaseModel):
title: str
url: str
class VideoCreate(VideoBase):
pass
class Video(VideoBase):
id: int
owner_id: int
created_at: datetime
votes: List[Vote] = []
class Config:
orm_mode = True
class UserBase(BaseModel):
username: str
email: EmailStr
class UserCreate(UserBase):
password: str
class User(UserBase):
id: int
created_at: datetime
videos: List[Video] = []
class Config:
orm_mode = True
class Token(BaseModel):
access_token: str
token_type: str
class TokenData(BaseModel):
username: Optional[str] = None