Skip to main content

MDocument

pipeline status coverage report pypi link

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

Usage

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(
        video=video._id,
        message="First!",
    )

    comment2 = await Comment.create(
        video=video._id,
        message="Second!"
    )

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Now we can easily access our comments using our related documents

TODO: REWRITE DOCUMENTATION!

Metadata

Release files for mdocument 4.0.1611942696

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdocument 4.0.1611942696
File Size Uploaded Provenance Actions
mdocument-4.0.1611942696.tar.gz 10.5 kB Without provenance Details for mdocument-4.0.1611942696.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mdocument 4.0.1611942696
File Interpreter ABI Platform Actions
mdocument-4.0.1611942696-py3-none-any.whl Python 3 none any Details for mdocument-4.0.1611942696-py3-none-any.whl

Total release size: 23.7 kB

Release files / mdocument-4.0.1611942696.tar.gz

Download URL mdocument-4.0.1611942696.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
56b67afffa893074759819e342f67784a49aacbcbc7d1d27dc1eab9a63ef2cad
BLAKE2b-256 checksum
How to use checksums
ff40f3754e642a34845974f312c98598301dff2e151b203c5eddd43d180574b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / mdocument-4.0.1611942696-py3-none-any.whl

Download URL mdocument-4.0.1611942696-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46a0ae0aa8cd17eb05b554f88b9b2fc514b488a311bea04030317ff1ce0e1c01
BLAKE2b-256 checksum
How to use checksums
b8eedb0cee0f40f71389e59534d873e873b2c57fdb4145db42c69b31c77d94bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Security for mdocument 4.0.1611942696

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page