Spaces:
Sleeping
Sleeping
File size: 442 Bytes
21c55a3 f24832a 21c55a3 f24832a 21c55a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# src/models/common.py
from typing import Annotated
from pydantic import BaseModel, BeforeValidator, ConfigDict, Field
PyObjectId = Annotated[str, BeforeValidator(str)]
class BaseMongoModel(BaseModel):
"""A base Pydantic model for all MongoDB documents."""
id: PyObjectId = Field(..., validation_alias="_id")
model_config = ConfigDict(
frozen=True,
from_attributes=True,
arbitrary_types_allowed=True,
populate_by_name=True
)
|