You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm going to define some documents that all of them have the 3 fields: uuid, created_at, modified_at.
I used the following code for inheritance, but the BaseDocument will be created as a separate collection and this makes further errors.
I only need to this BaseDocument be a abstract document not a real one.
Thanks
class BaseDocument(Document):
uuid: str = Field(default_factory=lambda: str(uuid4()))
created_at: datetime = Field(default_factory=datetime.utcnow)
modified_at: datetime | None = None
class Settings:
is_root = True
class SampleDocument(BaseDocument):
name: str
After I try to setup the database and collections, it creates 2 collections: BaseDocument + SampleDocument
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm going to define some documents that all of them have the 3 fields: uuid, created_at, modified_at.
I used the following code for inheritance, but the BaseDocument will be created as a separate collection and this makes further errors.
I only need to this BaseDocument be a abstract document not a real one.
Thanks
After I try to setup the database and collections, it creates 2 collections: BaseDocument + SampleDocument
Beta Was this translation helpful? Give feedback.
All reactions