Skip to content

musyoka-morris/pymongoext

Repository files navigation

Pymongoext

Pymongoext is an ORM-like Pymongo extension that adds json schema validation, index management and intermediate data manipulators. Pymongoext simplifies working with MongoDB, while maintaining a syntax very identical to Pymongo.

pymongoext.Model is simply a wrapper around pymongo.Collection. As such, all of the pymongo.Collection API is exposed through pymongoext.Model. If you don't find what you want in the pymongoext.Model API, please take a look at pymongo's Collection documentation.

Documentation is available at https://pymongoext.readthedocs.io

The code is hosted on Github https://github.com/musyoka-morris/pymongoext

Features

  • schema validation (which uses MongoDB JSON Schema validation)
  • schema-less feature
  • nested and complex schema declaration
  • untyped field support
  • required fields validation
  • default values
  • custom validators
  • operator for validation (OneOf, AllOf, AnyOf, Not)
  • indexes management
  • data manipulators (transform documents before saving and after retrieval)
  • Easy to create custom data manipulators
  • object-like results instead of dict-like. (i.e. foo.bar instead of foo['bar'])
  • No custom-query language or API to learn (If you know how to use pymongo, you already know how to use pymongoext)

Supported MongoDB & Python Versions

Pymongoext uses JSON Schema for validation and thus we only support MongoDB v3.6+.

Pymongoext supports python v3+. Support for python v2.7 is currently under consideration.

Installation

We recommend the use of virtualenv and of pip. You can then use pip install -U pymongoext.

You may also have setuptools and thus you can use easy_install -U pymongoext. Another option is pipenv. You can then use pipenv install pymongoext to both create the virtual environment and install the package.

Alternatively, you can download the source from GitHub and run python setup.py install.

Examples

Some simple examples of what pymongoext code looks like:

Contributing

We welcome contributions! See the Contribution guidelines

Releases

No releases published

Packages

No packages published

Languages