Async MongoDB with vanilla Pydantic v2+ - made easy.
MIT License
Source code: https://github.com/volfpeter/motorhead
Documentation and examples: https://volfpeter.github.io/motorhead
Async MongoDB with vanilla Pydantic v2+ - made easy.
Key features:
Pydantic
v2+.By providing a convenient, declarative middle layer between MongoDB and your API, motorhead
is halfway between an object document mapper (based on vanilla Pydantic
) and a database driver (by wrapping the official, async motor
driver). What's missing is the built-in ODM performance and memory overhead, whose benefits are rarely felt when working with document databases.
See the full documentation here.
The library is available on PyPI and can be installed with:
$ pip install motorhead
See the documentation for usage and application examples.
The project depends on motor
(the official asyncio MongoDB driver, which is built on top of pymongo
and bson
) and pydantic
v2+.
Use black
for code formatting, mypy
for static code analysis, ruff
for linting, and pytest
(with pytest-asyncio
and pytest-docker
) for testing.
The documentation is built with mkdocs-material
and mkdocstrings
.
All contributions are welcome.
This project is the continuation of fastapi-motor-oil with support for Pydantic v2, among other improvements. Migration from fastapi-motor-oil
should be easy, but if you need help, just create an issue in the issue tracker.
The library is open-sourced under the conditions of the MIT license.