Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codello/Motor-ODM
A MongoDB ODM based on Motor and Pydantic.
https://github.com/codello/Motor-ODM
asyncio mongodb motor odm pydantic pymongo python3
Last synced: 14 days ago
JSON representation
A MongoDB ODM based on Motor and Pydantic.
- Host: GitHub
- URL: https://github.com/codello/Motor-ODM
- Owner: codello
- License: mit
- Created: 2020-04-06T10:18:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-03T20:56:58.000Z (2 months ago)
- Last Synced: 2024-10-02T06:54:59.742Z (about 1 month ago)
- Topics: asyncio, mongodb, motor, odm, pydantic, pymongo, python3
- Language: Python
- Size: 95.7 KB
- Stars: 17
- Watchers: 4
- Forks: 5
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Motor-ODM
[![Build](https://github.com/Codello/Motor-ODM/workflows/Build/badge.svg)](https://github.com/Codello/Motor-ODM/actions?query=workflow%3ABuild)
[![Documentation Status](https://readthedocs.org/projects/motor-odm/badge/?version=latest)](https://motor-odm.readthedocs.io/en/latest/?badge=latest)
[![Codecov](https://img.shields.io/codecov/c/github/Codello/Motor-ODM)](https://codecov.io/gh/Codello/Motor-ODM)
[![Requirements Status](https://requires.io/github/Codello/Motor-ODM/requirements.svg?branch=master)](https://requires.io/github/Codello/Motor-ODM/requirements/?branch=master)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Motor-ODM)](https://pypi.org/project/Motor-ODM/)
[![PyPI](https://img.shields.io/pypi/v/Motor-ODM)](https://pypi.org/project/Motor-ODM/)![License](https://img.shields.io/github/license/Codello/Motor-ODM)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)A MongoDB ODM based on Motor and Pydantic.
The project code is hosted on [GitHub](https://github.com/Codello/Motor-ODM), documentation on [ReadTheDocs](https://motor-odm.readthedocs.io/).
## Installation
```shell script
pip install Motor-ODM
```## Quick Start
```python
from motor.motor_asyncio import AsyncIOMotorClient
from motor_odm import Document# Create a custom model by subclassing Document
class User(Document):
class Mongo:
# Set the collection name
collection = "users"
# Add attributes to your model
username: str
age: int# Connect your model to a database
client = AsyncIOMotorClient(...)
Document.use(client.get_default_database())# Create documents and save them to the database
u = User(username="John", age=20)
await u.insert()# Query the database
async for user in User.all():
print(user.username)
```For a more complete overview have a look at the [docs](https://motor-odm.readthedocs.io/).