{"id":14956907,"url":"https://github.com/musyoka-morris/pymongoext","last_synced_at":"2025-10-24T10:31:05.793Z","repository":{"id":57456164,"uuid":"176742548","full_name":"musyoka-morris/pymongoext","owner":"musyoka-morris","description":"An extension for pymongo that adds json schema validation and index management","archived":false,"fork":false,"pushed_at":"2019-10-19T08:10:09.000Z","size":112,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T14:21:22.664Z","etag":null,"topics":["indexes","jsonschema","mongo","mongodb","orm","pymongo","pymongo-wrapper","schema","validation"],"latest_commit_sha":null,"homepage":"https://pymongoext.readthedocs.io","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/musyoka-morris.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-20T13:42:07.000Z","updated_at":"2022-09-04T17:41:54.000Z","dependencies_parsed_at":"2022-09-14T05:00:43.765Z","dependency_job_id":null,"html_url":"https://github.com/musyoka-morris/pymongoext","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musyoka-morris%2Fpymongoext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musyoka-morris%2Fpymongoext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musyoka-morris%2Fpymongoext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musyoka-morris%2Fpymongoext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/musyoka-morris","download_url":"https://codeload.github.com/musyoka-morris/pymongoext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237950913,"owners_count":19392667,"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":["indexes","jsonschema","mongo","mongodb","orm","pymongo","pymongo-wrapper","schema","validation"],"created_at":"2024-09-24T13:13:42.716Z","updated_at":"2025-10-24T10:31:05.485Z","avatar_url":"https://github.com/musyoka-morris.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Pymongoext\n===========\n\nPymongoext is an ORM-like Pymongo extension that adds json schema validation,\nindex management and intermediate data manipulators.\nPymongoext simplifies working with MongoDB, while maintaining a syntax very identical to Pymongo.\n\n``pymongoext.Model`` is simply a wrapper around ``pymongo.Collection``.\nAs such, all of the pymongo.Collection API is exposed through pymongoext.Model.\nIf you don't find what you want in the pymongoext.Model API,\nplease take a look at pymongo's Collection documentation.\n\nDocumentation is available at https://pymongoext.readthedocs.io\n\nThe code is hosted on Github https://github.com/musyoka-morris/pymongoext\n\nFeatures\n=========\n\n- schema validation (which uses MongoDB JSON Schema validation)\n- schema-less feature\n- nested and complex schema declaration\n- untyped field support\n- required fields validation\n- default values\n- custom validators\n- operator for validation (OneOf, AllOf, AnyOf, Not)\n- indexes management\n- data manipulators (transform documents before saving and after retrieval)\n- Easy to create custom data manipulators\n- object-like results instead of dict-like. (i.e. foo.bar instead of foo['bar'])\n- No custom-query language or API to learn (If you know how to use pymongo, you already know how to use pymongoext)\n\nSupported MongoDB \u0026 Python Versions\n====================================\nPymongoext uses JSON Schema for validation and thus we only support\nMongoDB v3.6+.\n\nPymongoext supports python v3+. Support for python v2.7 is currently under consideration.\n\n\nInstallation\n=============\nWe recommend the use of `virtualenv \u003chttps://virtualenv.pypa.io\u003e`_ and of\n`pip \u003chttps://pip.pypa.io\u003e`_. You can then use ``pip install -U pymongoext``.\n\nYou may also have `setuptools \u003chttp://peak.telecommunity.com/DevCenter/setuptools\u003e`_\nand thus you can use ``easy_install -U pymongoext``. Another option is\n`pipenv \u003chttps://docs.pipenv.org\u003e`_. You can then use ``pipenv install pymongoext``\nto both create the virtual environment and install the package.\n\nAlternatively, you can download the source from `GitHub \u003chttps://github.com/musyoka-morris/pymongoext\u003e`_ and\nrun ``python setup.py install``.\n\nExamples\n=========\nSome simple examples of what pymongoext code looks like:\n\n.. code :: python\n\n    from datetime import datetime\n    from pymongo import MongoClient, IndexModel\n    from pymongoext import *\n\n\n    class User(Model):\n        @classmethod\n        def db(cls):\n            return MongoClient()['my_database_name']\n\n        __schema__ = DictField(dict(\n            email=StringField(required=True),\n            name=StringField(required=True),\n            yob=IntField(minimum=1900, maximum=2019)\n        ))\n\n        __indexes__ = [IndexModel('email', unique=True), 'name']\n\n        class AgeManipulator(Manipulator):\n            def transform_outgoing(self, doc, model):\n                doc['age'] = datetime.now().year - doc['yob']\n                return doc\n\n\n    # Create a user\n    \u003e\u003e\u003e User.insert_one({'email': 'jane@gmail.com', 'name': 'Jane Doe', 'yob': 1990})\n\n    # Fetch one user\n    \u003e\u003e\u003e user = User.find_one()\n\n    # Print the users age\n    \u003e\u003e\u003e print(user.age)\n\nContributing\n=============\nWe welcome contributions!\nSee the `Contribution guidelines \u003chttps://github.com/musyoka-morris/pymongoext/blob/master/CONTRIBUTING.rst\u003e`_","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusyoka-morris%2Fpymongoext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmusyoka-morris%2Fpymongoext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusyoka-morris%2Fpymongoext/lists"}