{"id":15441977,"url":"https://github.com/aminalaee/mongox","last_synced_at":"2025-04-13T05:22:26.409Z","repository":{"id":38828605,"uuid":"427307513","full_name":"aminalaee/mongox","owner":"aminalaee","description":"Familiar async Python MongoDB ODM","archived":false,"fork":false,"pushed_at":"2023-03-01T09:00:21.000Z","size":720,"stargazers_count":122,"open_issues_count":9,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-24T09:45:01.630Z","etag":null,"topics":["asgi","asyncio","mongodb","motor","pydantic","python","starlette"],"latest_commit_sha":null,"homepage":"https://aminalaee.github.io/mongox","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aminalaee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2021-11-12T09:49:07.000Z","updated_at":"2024-08-09T05:08:00.000Z","dependencies_parsed_at":"2025-02-25T09:21:17.598Z","dependency_job_id":null,"html_url":"https://github.com/aminalaee/mongox","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminalaee%2Fmongox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminalaee%2Fmongox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminalaee%2Fmongox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminalaee%2Fmongox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aminalaee","download_url":"https://codeload.github.com/aminalaee/mongox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248666922,"owners_count":21142344,"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":["asgi","asyncio","mongodb","motor","pydantic","python","starlette"],"created_at":"2024-10-01T19:24:43.887Z","updated_at":"2025-04-13T05:22:26.388Z","avatar_url":"https://github.com/aminalaee.png","language":"Python","funding_links":[],"categories":["Object Mapping"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/aminalaee/mongox\"\u003e\n    \u003cimg width=\"420px\" src=\"https://raw.githubusercontent.com/aminalaee/mongox/main/docs/assets/images/banner.png\" alt\"MongoX\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/aminalaee/mongox/actions\"\u003e\n    \u003cimg src=\"https://github.com/aminalaee/mongox/workflows/Test%20Suite/badge.svg\" alt=\"Build Status\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/aminalaee/mongox/actions\"\u003e\n    \u003cimg src=\"https://github.com/aminalaee/mongox/workflows/Publish/badge.svg\" alt=\"Publish Status\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/aminalaee/mongox\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/aminalaee/mongox/branch/main/graph/badge.svg\" alt=\"Coverage\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/mongox/\"\u003e\n    \u003cimg src=\"https://badge.fury.io/py/mongox.svg\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/mongox\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/mongox.svg?color=%2334D058\" alt=\"Supported Python versions\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n# MongoX\n\nMongoX is an async python ODM (Object Document Mapper) for MongoDB\nwhich is built on top of [Motor][motor] and [Pydantic][pydantic].\n\nThe main features include:\n\n* Fully type annotated\n* Async support Python 3.7+ (since it's built on top of Motor)\n* Elegant editor support (since it's built on top of Pydantic)\n* Autocompletion everywhere, from object creation to query results\n* Custom query builder which is more intuitive and pythonic\n* 100% test coverage\n\nMongoX models are at the same time Pydantic models and have the same functionalitties,\nso you can use them with your existing Pydantic models.\n\n---\n\n**Documentation**: [https://aminalaee.github.io/mongox](https://aminalaee.github.io/mongox)\n\n---\n\n## Installation\n\n```shell\n$ pip install mongox\n```\n\n---\n\n## Quickstart\n\nYou can define `mongox` models the same way you define Pydantic models.\nThe difference is they should inherit from `mongox.Model` now:\n\n```python\nimport asyncio\n\nimport mongox\n\nclient = mongox.Client(\"mongodb://localhost:27017\")\ndb = client.get_database(\"test_db\")\n\n\nclass Movie(mongox.Model, db=db, collection=\"movies\"):\n    name: str\n    year: int\n```\n\nNow you can create some instances and insert them into the database:\n\n```python\nmovie = await Movie(name=\"Forrest Gump\", year=1994).insert()\n```\n\nThe returned result will be a `Movie` instance, and `mypy`\nwill understand that this is a `Movie` instance.\nSo you will have type hints and validations everywhere.\n\nNow you can fetch some data from the database.\n\nYou can use the same pattern as PyMongo/Motor:\n\n```python\nmovie = await Movie.query({\"name\": \"Forrest Gump\"}).get()\n```\n\nOr you can use `Movie` fields instead of dictionaries in the query (less room for bugs):\n\n```python\nmovie = await Movie.query({Movie.name: \"Forrest Gump\"}).get()\n```\n\nAnd finally you can use a more intuitive query (limited yet):\n\n```python\nmovie = await Movie.query(Movie.name == \"Forrest Gump\").get()\n```\n\nNotice how we omitted the dictionary and passed the `Movie` fields in comparison.\n\n---\n\nPlease refer to the documentation [here](https://aminalaee.github.io/mongox) or the full examples [here](https://github.com/aminalaee/mongox/tree/main/examples).\n\n---\n\n[motor]: https://github.com/mongodb/motor\n[pydantic]: https://github.com/samuelcolvin/pydantic\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminalaee%2Fmongox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faminalaee%2Fmongox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminalaee%2Fmongox/lists"}