Skip to main content

A MongoDB ODM based on Motor and Pydantic.

Project description

Motor-ODM

Build Documentation Status Codecov Requirements Status PyPI - Python Version PyPI

License Code style: black

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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Motor_ODM-0.1.dev0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

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

Hashes for Motor-ODM-0.1.dev0.tar.gz
Algorithm Hash digest
SHA256 a604e7335db1be22718f51f9fee10f015c8777a112457e31e0d28a2afc0346ca
MD5 108bf04d728c477008f1a64044f25b12
BLAKE2b-256 79a3bd11f8307ffd67cef991da60198408353b988b9e70d509c8a5a1041c7f18

See more details on using hashes here.

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

Hashes for Motor_ODM-0.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 86bc245ed8c54f72e833f71985785b0132f6f181527bc5de6a4f3a67301d5022
MD5 19cf2c22f815c4b6273791e3be95a326
BLAKE2b-256 8d3e2e6dc5e6cddcfce5b3ccee768206285af6123eb6bc1dd2992fbf812c024c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page