55 lines
1.1 KiB
Python

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