Skip to main content

Simple DRM for motor client

Project description

pipeline status coverage report pypi link

MDocument is a simple ORM for MongoDB with addition of relations.


There are two ways of using mdocument: 1. Specify database, colleciton and client in class. 2. Use modified mongo motor client.

Specifying document parameters in class

import asyncio

import motor.motor_asyncio

from mdocument import MDocument, relations, model

client = motor.motor_asyncio.AsyncIOMotorClient()

class Video(MDocument):
    __collection__ = "videos"
    __database__ = "mdocument"
    __client__ = client

    class Model(MDocument.Model):
        title = model.Field(str)
        views_count = model.Field(int)
        public_id = model.Field(str, unique=True)

class Comment(MDocument):
    __collection__ = "comments"
    __database__ = "mdocument"
    __client__ = client

    class Model(MDocument.Model):
        text = model.Field(str)
        video = model.FieldSync(Video, relation=relations.RelationOneToMany, synced_fields=["_id", "title"])

async def main():
    video = await Video.create({"title": "Test"})

    comment1 = await Comment.create(

    comment2 = await Comment.create(

loop = asyncio.get_event_loop()

Now we can easily access our comments using our related documents


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

mdocument-4.0.1612576120.tar.gz (10.8 kB view hashes)

Uploaded source

Built Distribution

mdocument-4.0.1612576120-py3-none-any.whl (13.5 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page