Skip to main content

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!

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.1612470861.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

mdocument-4.0.1612470861-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file mdocument-4.0.1612470861.tar.gz.

File metadata

  • Download URL: mdocument-4.0.1612470861.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for mdocument-4.0.1612470861.tar.gz
Algorithm Hash digest
SHA256 136eabbfb1e8f23278bd7344e43e476466ffddada66a1acad1163c0fd1cc9b36
MD5 d34ef8119258f4dc1c9de6f677f631c1
BLAKE2b-256 c991c457835f4b4c3787f91d103d539c4550974cc4c0dc4d3b8674761ab5fcb4

See more details on using hashes here.

File details

Details for the file mdocument-4.0.1612470861-py3-none-any.whl.

File metadata

  • Download URL: mdocument-4.0.1612470861-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for mdocument-4.0.1612470861-py3-none-any.whl
Algorithm Hash digest
SHA256 baf28ebddb430c05c379e9ba1cd5508cc46426aa1fc77147b5a4ba579bb8847c
MD5 c2f5c09b43a561238513d3fbb3e0cd44
BLAKE2b-256 ec5d0737d9fac70171ae330d2d006878d13ad081063f123038e0752f2f563b67

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

4.0.1612470861 This release

2 files

4.0.1611942696

2 files

4.0.1611942618

2 files

4.0.1611941755

2 files

4.0.1610663369

2 files

3.0.1647176776

2 files

3.0.1595801911

2 files

3.0.1595701480

2 files

3.0.1592410567

2 files

3.0.1592349929

2 files

3.0.1592254420

2 files

3.0.1592083234

2 files

3.0.1591920385

2 files

3.0.1590436924

2 files

3.0.1590238503

2 files

3.0.1586563022

2 files

3.0.1586561692

2 files

3.0.1585480453

2 files

3.0.1585479864

2 files

3.0.1585444432

2 files

2.1.1585444647

2 files

2.1.1585431917

2 files

2.1.1585400186

2 files

2.1.1585339565

2 files

2.1.1585249863

2 files

2.1.1585186501

2 files

2.0.1585164327

2 files

2.0.1585164170

2 files

2.0.1585152707

2 files

2.0.1585145723

2 files

2.0.1585096896

2 files

2.0.1584903176

2 files

1.0.1584890051

2 files

1.0.1584886606

1 file

1.0.1584885381

1 file

1.0.1584884718

1 file

1.0.1584829858

1 file

1.0.1584829687

1 file

1.0.1584797184

1 file

1.0.1584796898

1 file

1.0.1584796579

1 file

1.0.1584794233

1 file

1.0.1584793540

1 file

1.0.1584793409

1 file

0.6.1585444356

1 file

0.6.1584791178

1 file

0.6.1584790699

1 file

0.6.1584789593

1 file

0.5.1585444358

1 file

0.5.1584793101

1 file

0.5.1584787952

1 file

0.5

1 file

0.4

1 file

0.3

1 file

0.2

1 file

0.1

1 file

Supported by

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