{ "info": { "author": "Yaroslav Unknown", "author_email": "yaroslav@gmx.it", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: AsyncIO", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.7", "Topic :: Software Development", "Topic :: Software Development :: Libraries" ], "description": "# monypy - asynchronous lightweight ODM for MongoDB based on [motor](https://github.com/mongodb/motor)\n\n[![Build Status](https://travis-ci.org/nede1/monypy.svg?branch=master)](https://travis-ci.org/nede1/monypy)\n\n## Dependencies ##\n```\npython <= 3.7\nmotor >= 2.0\n```\n\n## Installation ##\n```bash\npipenv install monypy\n```\n\n## Quick Start ##\n```python\nimport asyncio\nfrom monypy import Doc\n\n\nclass User(Doc):\n __init_data__ = {\n 'sex': 'male',\n 'instance_id': lambda i: id(i)\n }\n \n __database__ = {\n 'name': 'test',\n 'host': 'localhost',\n 'port': 27017\n }\n \nuser = User(name='John')\n\nassert '_id' not in user\nassert user.name == 'John'\nassert user.sex == 'male'\n\nassert not callable(user.instance_id)\nassert user.instance_id == id(user)\n\nasyncio.run(user.save())\n\nassert '_id' in user\n```\n\n## API Reference ##\n\n### Doc ###\n* #### `__database__` ####\n Attribute for setting up the database. Parameters:\n * `name` - the name of the database\n \n List of other optional parameters [here](https://api.mongodb.com/python/current/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient).\n \n* #### `__collection__` ####\n __optional__. Attribute for setting up the collection. Parameters: \n * `name` - the name of the collection\n\n* #### `__abstract__` ####\n __optional__. If `True`, then the collection will not create a connection to the database.\n\n* #### `__init_data__` ####\n __optional__. Set the initializing data for all objects in the collection when the object is initialized. If the value is callable, an instance will be passed as an argument.\n\n* #### `save()` ####\n __\u0441oroutine__. It saves the object in the database.\n\n* #### `delete()` ####\n __\u0441oroutine__. It remove an object from the database. If the object does not exist in the database, then the __DocumentDoesNotExist__ exception will be raised.\n\n* #### `refresh()` ####\n __\u0441oroutine__. Refresh the current object from the same object from the database. If the object does not exist in the database, then the __DocumentDoesNotExist__ exception will be raised.\n\n### Manager ###\nA simple wrapper over [AsyncIOMotorCollection](https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection).\n\n* #### `create(**kwargs)` ####\n __\u0441oroutine__. Create an object and return it.\n \n* #### `count(filter, session=None, **kwargs)` ####\n __\u0441oroutine__. Simple alias on [count_documents](https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html#motor.motor_asyncio.AsyncIOMotorCollection.count_documents).\n\nFor example:\n```python\nfrom monypy import Doc, Manager\n\nclass UserManager(Manager):\n async def count_active(self):\n return await self.count_documents({'active': True})\n\nclass SecondUserManager(Manager):\n async def count_not_active(self):\n return await self.count_documents({'active': False})\n \n \nclass User(Doc):\n documents = UserManager()\n second_documents = SecondUserManager()\n\n __database__ = {\n 'name': 'test'\n }\n \n __init_data__ = {\n 'active': True,\n }\n\nawait User().save()\nawait User(active=False).save()\n\nassert await User.documents.count() == 2\nassert await User.documents.count_active() == 1\nassert await User.second_documents.count_not_active() == 1\n\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/nede1/monypy", "keywords": "asyncio mongodb motor odm", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "monypy", "package_url": "https://pypi.org/project/monypy/", "platform": "", "project_url": "https://pypi.org/project/monypy/", "project_urls": { "Homepage": "http://github.com/nede1/monypy" }, "release_url": "https://pypi.org/project/monypy/2.0.1/", "requires_dist": null, "requires_python": "", "summary": "Asynchronous lightweight ODM for mongodb based on motor", "version": "2.0.1" }, "last_serial": 4673012, "releases": { "1.0.3": [ { "comment_text": "", "digests": { "md5": "bd25e766a47b2e086dc4958dff4a018f", "sha256": "a970d5b387bd857ce141ab6b48fff331ff5edd84d7e17dce13ed59928bed1ae8" }, "downloads": -1, "filename": "monypy-1.0.3.tar.gz", "has_sig": false, "md5_digest": "bd25e766a47b2e086dc4958dff4a018f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4871, "upload_time": "2018-06-17T15:11:58", "url": "https://files.pythonhosted.org/packages/dc/a4/6895f69716b9e325e4090f261ab296f216a57f40758e9c91f39fe6e369ef/monypy-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "3113a8acb3bd3b98afd6744ca9961541", "sha256": "26664f28be5602778efe0333deebb961379c395298b91feed8fd37f277763d52" }, "downloads": -1, "filename": "monypy-1.0.4.tar.gz", "has_sig": false, "md5_digest": "3113a8acb3bd3b98afd6744ca9961541", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4873, "upload_time": "2018-06-19T05:59:10", "url": "https://files.pythonhosted.org/packages/4c/f6/e38b71f94d0f039d295a413290bec3652eeccacbc01ca9e1950c8e60229b/monypy-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "e262a2dd37c9a4be4d729669580b4138", "sha256": "e7af7b3c421c0e15536e86b09f5a1aea66d2f14c83716e00a6ff44be0bdc1b50" }, "downloads": -1, "filename": "monypy-1.0.5.tar.gz", "has_sig": false, "md5_digest": "e262a2dd37c9a4be4d729669580b4138", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4937, "upload_time": "2018-06-20T20:15:22", "url": "https://files.pythonhosted.org/packages/8b/ea/ae7e1ab2815133981762f9ec0782bf68210aa5643e44410ed474b9389302/monypy-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "2d6bea334eb08b6ea09a57afcf48f356", "sha256": "b2678f280b7934dc4a40dc798cec2445204d76d14be41eb55966427b6b674942" }, "downloads": -1, "filename": "monypy-1.0.6.tar.gz", "has_sig": false, "md5_digest": "2d6bea334eb08b6ea09a57afcf48f356", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4970, "upload_time": "2018-07-08T06:03:46", "url": "https://files.pythonhosted.org/packages/90/31/7c86a4675c0a5674eeb82574fc08c7420134cf1f7dc39eb0e1e2305c7bfe/monypy-1.0.6.tar.gz" } ], "2.0": [ { "comment_text": "", "digests": { "md5": "96873b0dcdb1384fa83e0eb056cc5cfa", "sha256": "863c5190fa3a1e9448224f0271ff43202849d8c73bcc9cb5db5f10ea78c55d14" }, "downloads": -1, "filename": "monypy-2.0.tar.gz", "has_sig": false, "md5_digest": "96873b0dcdb1384fa83e0eb056cc5cfa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4915, "upload_time": "2018-11-11T18:29:19", "url": "https://files.pythonhosted.org/packages/33/19/de67dee28e8ffd9878fa790a268d9016e8ed8bff50eba7dd63fe50398dd2/monypy-2.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "ca022a9a5f34a0c71155495b78967876", "sha256": "a28338e2f72e3770f1a59aa879a15e18568072a13af050ff71a6412c3fd7103d" }, "downloads": -1, "filename": "monypy-2.0.1.tar.gz", "has_sig": false, "md5_digest": "ca022a9a5f34a0c71155495b78967876", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4981, "upload_time": "2019-01-08T13:39:49", "url": "https://files.pythonhosted.org/packages/f5/d3/8a7853a9fafc78b31b233fd4e61ac02fffd0b73c50668be3c7573df591ce/monypy-2.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ca022a9a5f34a0c71155495b78967876", "sha256": "a28338e2f72e3770f1a59aa879a15e18568072a13af050ff71a6412c3fd7103d" }, "downloads": -1, "filename": "monypy-2.0.1.tar.gz", "has_sig": false, "md5_digest": "ca022a9a5f34a0c71155495b78967876", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4981, "upload_time": "2019-01-08T13:39:49", "url": "https://files.pythonhosted.org/packages/f5/d3/8a7853a9fafc78b31b233fd4e61ac02fffd0b73c50668be3c7573df591ce/monypy-2.0.1.tar.gz" } ] }