A MongoDB ODM based on Motor and Pydantic.
Project description
Motor-ODM
A MongoDB ODM based on Motor and Pydantic.
The project code is hosted on GitHub, documentation on ReadTheDocs.
Installation
pip install Motor-ODM
Quick Start
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Motor-ODM-0.1.dev0.tar.gz
(17.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Motor-ODM-0.1.dev0.tar.gz.
File metadata
- Download URL: Motor-ODM-0.1.dev0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a604e7335db1be22718f51f9fee10f015c8777a112457e31e0d28a2afc0346ca
|
|
| MD5 |
108bf04d728c477008f1a64044f25b12
|
|
| BLAKE2b-256 |
79a3bd11f8307ffd67cef991da60198408353b988b9e70d509c8a5a1041c7f18
|
File details
Details for the file Motor_ODM-0.1.dev0-py3-none-any.whl.
File metadata
- Download URL: Motor_ODM-0.1.dev0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86bc245ed8c54f72e833f71985785b0132f6f181527bc5de6a4f3a67301d5022
|
|
| MD5 |
19cf2c22f815c4b6273791e3be95a326
|
|
| BLAKE2b-256 |
8d3e2e6dc5e6cddcfce5b3ccee768206285af6123eb6bc1dd2992fbf812c024c
|