-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
48 lines (31 loc) · 1.05 KB
/
models.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
from typing import List, Optional
from bson import ObjectId
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_serializer
class PetModel (BaseModel):
id: Optional[ObjectId] = Field(alias="_id", default=None)
nome_pet: Optional[str] = None
especie: Optional[str] = None
model_config = ConfigDict(
arbitrary_types_allowed=True)
@field_serializer('id')
def serialize_id(self, id):
return str(id)
class UpdatePetModel(BaseModel):
nome_pet: Optional[str] = None
especie: Optional[str] = None
class PetList(RootModel):
root: List[PetModel]
class PetshopModel(BaseModel):
id: Optional[ObjectId] = Field(alias="_id", default=None)
nome_petshop: str
descricao: str
model_config = ConfigDict(
arbitrary_types_allowed=True)
@field_serializer('id')
def serialize_id(self, id):
return str(id)
class UpdatePetshopModel(BaseModel):
nome_petshop: Optional[str] = None
descricao: Optional[str] = None
class PetshopList(RootModel):
root: List[PetshopModel]