We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My previous models all have fields such as _date_created which I would like to support by having a base document model such as:
_date_created
class BaseMongoModel(Model): date_created: datetime = Field(default_factory=datetime.utcnow) class Tree(BaseMongoModel): name: str average_size: float discovery_year: int
However when trying to apply something with the engine, I get the error:
TypeError: Can only call find with a Model class
Implement a base model class and allow inheritance
This could be solved using composition, such as:
class Metadata(EmbeddedModel): date_created: datetime = Field(default_factory=datetime.utcnow) class Tree(Model): metadata: Metadata = Field(default_factory=Metadata) name: str average_size: float discovery_year: int
However for this use case, I think I would prefer inheritance to ensure that all new models have this data.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Feature request
Context
My previous models all have fields such as
_date_created
which I would like to support by having a base document model such as:However when trying to apply something with the engine, I get the error:
Solution
Implement a base model class and allow inheritance
Alternative solutions
This could be solved using composition, such as:
However for this use case, I think I would prefer inheritance to ensure that all new models have this data.
The text was updated successfully, but these errors were encountered: