{"id":14956770,"url":"https://github.com/beanieodm/beanie","last_synced_at":"2025-12-12T00:35:35.412Z","repository":{"id":37958989,"uuid":"341677148","full_name":"BeanieODM/beanie","owner":"BeanieODM","description":"Asynchronous Python ODM for MongoDB","archived":false,"fork":false,"pushed_at":"2024-10-28T20:37:18.000Z","size":1752,"stargazers_count":2046,"open_issues_count":89,"forks_count":217,"subscribers_count":18,"default_branch":"main","last_synced_at":"2024-10-29T14:21:02.841Z","etag":null,"topics":["async","asynchronous","asyncio","beanie","mongo","mongodb","motor","odm","orm","pydantic","pymongo","python"],"latest_commit_sha":null,"homepage":"http://beanie-odm.dev/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BeanieODM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"romanright"}},"created_at":"2021-02-23T20:11:23.000Z","updated_at":"2024-10-29T09:35:02.000Z","dependencies_parsed_at":"2023-10-03T02:59:56.961Z","dependency_job_id":"2a0eaa4c-1b0f-4a93-a569-4ead19007bdd","html_url":"https://github.com/BeanieODM/beanie","commit_stats":{"total_commits":442,"total_committers":100,"mean_commits":4.42,"dds":0.5791855203619909,"last_synced_commit":"602e3777919ecc357adb2b94e62c960908187a4d"},"previous_names":["roman-right/beanie"],"tags_count":122,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeanieODM%2Fbeanie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeanieODM%2Fbeanie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeanieODM%2Fbeanie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeanieODM%2Fbeanie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BeanieODM","download_url":"https://codeload.github.com/BeanieODM/beanie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261934,"owners_count":21074226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","asynchronous","asyncio","beanie","mongo","mongodb","motor","odm","orm","pydantic","pymongo","python"],"created_at":"2024-09-24T13:13:28.946Z","updated_at":"2025-11-20T21:05:34.444Z","avatar_url":"https://github.com/BeanieODM.png","language":"Python","funding_links":["https://ko-fi.com/romanright"],"categories":[],"sub_categories":[],"readme":"[![Beanie](https://raw.githubusercontent.com/roman-right/beanie/main/assets/logo/white_bg.svg)](https://github.com/roman-right/beanie)\n\n[![shields badge](https://shields.io/badge/-docs-blue)](https://beanie-odm.dev)\n[![pypi](https://img.shields.io/pypi/v/beanie.svg)](https://pypi.python.org/pypi/beanie)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/BeanieODM/beanie/main.svg)](https://results.pre-commit.ci/latest/github/BeanieODM/beanie/main)\n\n\n\n## 📢 Important Update 📢\n\nWe are excited to announce that Beanie is transitioning from solo development to a team-based approach! This move will help us enhance the project with new features and more collaborative development.\n\nAt this moment we are establishing a board of members that will decide all the future steps of the project. We are looking for contributors and maintainers to join the board.\n\n### Join Us\nIf you are interested in contributing or want to stay updated, please join our Discord channel. We're looking forward to your ideas and contributions!\n\n[Join our Discord](https://discord.gg/AwwTrbCASP)\n\nLet’s make Beanie better, together!\n\n## Overview\n\n[Beanie](https://github.com/roman-right/beanie) - is an asynchronous Python object-document mapper (ODM) for MongoDB. Data models are based on [Pydantic](https://pydantic-docs.helpmanual.io/).\n\nWhen using Beanie each database collection has a corresponding `Document` that\nis used to interact with that collection. In addition to retrieving data,\nBeanie allows you to add, update, or delete documents from the collection as\nwell.\n\nBeanie saves you time by removing boilerplate code, and it helps you focus on\nthe parts of your app that actually matter.\n\nData and schema migrations are supported by Beanie out of the box.\n\nThere is a synchronous version of Beanie ODM - [Bunnet](https://github.com/roman-right/bunnet)\n\n## Installation\n\n### PIP\n\n```shell\npip install beanie\n```\n\n### Poetry\n\n```shell\npoetry add beanie\n```\n\nFor more installation options (eg: `aws`, `gcp`, `srv` ...) you can look in the [getting started](./docs/getting-started.md#optional-dependencies)\n\n## Example\n\n```python\nimport asyncio\nfrom typing import Optional\n\nfrom pymongo import AsyncMongoClient\nfrom pydantic import BaseModel\n\nfrom beanie import Document, Indexed, init_beanie\n\n\nclass Category(BaseModel):\n    name: str\n    description: str\n\n\nclass Product(Document):\n    name: str                          # You can use normal types just like in pydantic\n    description: Optional[str] = None\n    price: Indexed(float)              # You can also specify that a field should correspond to an index\n    category: Category                 # You can include pydantic models as well\n\n\n# This is an asynchronous example, so we will access it from an async function\nasync def example():\n    # Beanie uses PyMongo async client under the hood\n    client = AsyncMongoClient(\"mongodb://user:pass@host:27017\")\n\n    # Initialize beanie with the Product document class\n    await init_beanie(database=client.db_name, document_models=[Product])\n\n    chocolate = Category(name=\"Chocolate\", description=\"A preparation of roasted and ground cacao seeds.\")\n    # Beanie documents work just like pydantic models\n    tonybar = Product(name=\"Tony's\", price=5.95, category=chocolate)\n    # And can be inserted into the database\n    await tonybar.insert() \n    \n    # You can find documents with pythonic syntax\n    product = await Product.find_one(Product.price \u003c 10)\n    \n    # And update them\n    await product.set({Product.name:\"Gold bar\"})\n\n\nif __name__ == \"__main__\":\n    asyncio.run(example())\n```\n\n## Links\n\n### Documentation\n\n- **[Doc](https://beanie-odm.dev/)** - Tutorial, API documentation, and development guidelines.\n\n### Example Projects\n\n- **[fastapi-cosmos-beanie](https://github.com/tonybaloney/ants-azure-demos/tree/master/fastapi-cosmos-beanie)** - FastAPI + Beanie ODM + Azure Cosmos Demo Application by [Anthony Shaw](https://github.com/tonybaloney)\n- **[fastapi-beanie-jwt](https://github.com/flyinactor91/fastapi-beanie-jwt)** - \n  Sample FastAPI server with JWT auth and Beanie ODM by [Michael duPont](https://github.com/flyinactor91)\n- **[Shortify](https://github.com/IHosseini083/Shortify)** - URL shortener RESTful API (FastAPI + Beanie ODM + JWT \u0026 OAuth2) by [\nIliya Hosseini](https://github.com/IHosseini083)\n- **[LCCN Predictor](https://github.com/baoliay2008/lccn_predictor)** - Leetcode contest rating predictor (FastAPI + Beanie ODM + React) by [L. Bao](https://github.com/baoliay2008)\n\n### Articles\n\n- **[Announcing Beanie - MongoDB ODM](https://dev.to/romanright/announcing-beanie-mongodb-odm-56e)**\n- **[Build a Cocktail API with Beanie and MongoDB](https://developer.mongodb.com/article/beanie-odm-fastapi-cocktails/)**\n- **[MongoDB indexes with Beanie](https://dev.to/romanright/mongodb-indexes-with-beanie-43e8)**\n- **[Beanie Projections. Reducing network and database load.](https://dev.to/romanright/beanie-projections-reducing-network-and-database-load-3bih)**\n- **[Beanie 1.0 - Query Builder](https://dev.to/romanright/announcing-beanie-1-0-mongodb-odm-with-query-builder-4mbl)**\n- **[Beanie 1.8 - Relations, Cache, Actions and more!](https://dev.to/romanright/announcing-beanie-odm-18-relations-cache-actions-and-more-24ef)**\n\n### Resources\n\n- **[GitHub](https://github.com/roman-right/beanie)** - GitHub page of the\n  project\n- **[Changelog](https://beanie-odm.dev/changelog)** - list of all\n  the valuable changes\n- **[Discord](https://discord.gg/AwwTrbCASP)** - ask your questions, share\n  ideas or just say `Hello!!`\n\n----\nSupported by [JetBrains](https://jb.gg/OpenSource)\n\n[![JetBrains](https://raw.githubusercontent.com/roman-right/beanie/main/assets/logo/jetbrains.svg)](https://jb.gg/OpenSource)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeanieodm%2Fbeanie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeanieodm%2Fbeanie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeanieodm%2Fbeanie/lists"}