26 lines
562 B
Python
Raw Normal View History

2023-10-10 22:39:23 +02:00
from pydantic import BaseModel
2023-10-13 18:17:38 +02:00
from pydantic_mongo import AbstractRepository, ObjectIdField
2023-10-10 22:39:23 +02:00
2023-10-11 23:45:12 +02:00
class User(BaseModel):
2023-10-13 18:17:38 +02:00
id: ObjectIdField = None
2023-10-10 22:39:23 +02:00
username: str
2023-10-11 23:45:12 +02:00
password: str
2023-10-12 00:04:18 +02:00
roles: str
2023-10-14 18:20:08 +02:00
disabled: bool = False
removed: bool = False
confirmed: bool = False
2023-10-10 22:39:23 +02:00
2023-10-13 14:59:57 +02:00
class UserOut(BaseModel):
2023-10-13 18:17:38 +02:00
id: ObjectIdField = None
2023-10-13 14:59:57 +02:00
username: str
roles: str
disabled: bool
2023-10-14 18:20:08 +02:00
removed: bool
confirmed: bool
2023-10-13 14:59:57 +02:00
2023-10-11 23:45:12 +02:00
class UserInDB(User):
2023-10-13 18:17:38 +02:00
password: str
class UserRepository(AbstractRepository[User]):
class Meta:
collection_name = "users"