![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
🥭 带有类型提示的 Python 异步 MongoDB 对象文档映射器
Mango 是一个带有类型提示的 Python 异步 MongoDB 对象文档映射器(ODM),它构建在 Motor 和 Pydantic 之上。
Mango 使得数据建模和查询变得非常容易,帮助您关注应用程序中真正重要的部分。
[⬆回到顶部]
pip install mango-odm
poetry add mango-odm
[⬆回到顶部]
import asyncio
from mango import Document, EmbeddedDocument, Field, Mango
# 嵌入式文档
class Author(EmbeddedDocument):
name: str
profile: str | None = None
# Mango 文档模型
class Book(Document):
name: str = Field(primary_key=True) # 将字段设置为主键,如果不显式指定主键,则会自动创建 id 字段作为主键
summary: str | None = None
author: Author # 嵌入文档
price: int = Field(index=True) # 为字段添加索引
async def main():
# 初始化 Mango,它会创建连接并初始化文档模型,你可以传入 db 或者 uri 参数来指定连接
await Mango.init()
# 像 pydantic 的模型一样使用
book = Book(name="book", author=Author(name="author"), price=10)
# 将它插入到数据库中
await book.save()
# Mango 提供了丰富的查询语言,允许您使用 Python 表达式来查询
if book := await Book.find(Book.price <= 20, Book.author.name == "author").get():
# 更新文档的 summary 字段
book.summary = "summary"
await book.update()
if __name__ == "__main__":
asyncio.run(main())
[⬆回到顶部]
想为这个项目做出一份贡献吗?点击这里阅读并了解如何贡献。
感谢以下开发者对该项目做出的贡献:
[⬆回到顶部]
喜欢这个项目?请点亮 star 并分享它!
[⬆回到顶部]
在 MIT
许可证下分发。请参阅 LICENSE 以获取更多信息。
[⬆回到顶部]
FAQs
🥭 Async MongoDB ODM with type hints in Python
We found that mango-odm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.