odmantic模型从pydantic模型继承

发布于 2025-01-30 05:28:29 字数 238 浏览 2 评论 0原文

您好,亲爱的社区,

我正在与MongoDB操作的Engine合作,并且有一个从Pydantic模型继承的Odmantic模型。

OdmanticModel(Model, PydanticModel):
      attributes

Odmantic模型似乎没有考虑Pydantic模型属性,并且最终并未保存在MongoDB中。 是否有任何解决方案或工具使继承完全隐含或明确地工作

Hello dear community,

I am working with engine for mongodb operations and i have an odmantic model that inherit from a pydantic model.

OdmanticModel(Model, PydanticModel):
      attributes

It seems that odmantic model does not considerate pydantic model attribute, and these are not saved eventually in mongodb.
Is there any solution or a workarround to make the inheritance fully worked implicitly or explicitly

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你好,陌生人 2025-02-06 05:28:29

作为解决方案的替代方案,我使用了Beanie ODM,当涉及Pydantic和MongoDB模型相互作用时,它是完美的。

beanie-是基于电机和pydantic的蒙古德(Mongodb)的异步Python对象图案映射器(ODM)。

As an alternative for the solution, i used Beanie ODM, it is perfect when it comes to pydantic and mongodb models interactions.

Beanie - is an Asynchronous Python object-document mapper (ODM) for MongoDB, based on Motor and Pydantic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文