2023-10-23 23:45:13 +02:00

44 lines
920 B
Python

from pydantic import BaseModel, EmailStr
from pydantic_mongo import AbstractRepository, ObjectIdField
from datetime import datetime
class User(BaseModel):
id: ObjectIdField = None
username: str
password: str
roles: str = "User"
status: int = 0
email: EmailStr
birth: datetime = None
created_at: datetime = datetime.today()
connected_at: datetime = None
updated_at: datetime = datetime.today()
deleted_at: datetime = None
class UserOut(BaseModel):
id: ObjectIdField = None
username: str
roles: str
status: int = 0
email: EmailStr
class UserIn(BaseModel):
username: str
roles: str
password: str
email: EmailStr
class UserCreate(BaseModel):
username: str
password: str
email: EmailStr
class UserInDB(User):
password: str
class UserRepository(AbstractRepository[User]):
class Meta:
collection_name = "users"