joker-mongodb


Namejoker-mongodb JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/frozflame/joker-mongodb
Summaryaccess mongodb with handy utilities and fun
upload_time2024-05-06 02:57:57
maintainerNone
docs_urlNone
authorfrozflame
requires_python>=3.7.0
licenseGNU General Public License (GPL)
keywords
VCS
bugtrack_url
requirements joker-cast joker-textmanip joker pymongo volkanic
Travis-CI No Travis.
coveralls test coverage No coveralls.
            joker-mongodb
=============

Access mongodb with handy utilities and fun.

## Connnect to multiple mongo servers with MongoInterface

Example:

`GlobalInterface` is defined in `example/environ.py` as:

```python
from functools import cached_property

import volkanic
from joker.mongodb.interfaces import MongoInterface


class GlobalInterface(volkanic.GlobalInterface):
    package_name = 'example'
    default_config = {
        "mongoi": {
            "local": {},
            "remote": {
                "host": "192.168.22.122",
                "port": 27017
            }
        }
    }

    @cached_property
    def mongoi(self) -> MongoInterface:
        return MongoInterface.from_config(self.conf['mongoi'])
```

If a configuration file is found at one of the follow locations:

- Under your project directory in a development enviornment
- `~/.example/config.json5`
- `/etc/example/config.json5`
- `/example/config.json5`

it will override `GlobalInterface.default_config`.

Usage in code `example/application.py`:

```python
from bson import ObjectId
# noinspection PyUnresolvedReferences,PyPackageRequirements
from example.environ import GlobalInterface

gi = GlobalInterface()


def get_product(product_oid):
    coll = gi.mongoi.get_coll('remote', 'example', 'products')
    return coll.find_one({'_id': ObjectId(product_oid)})


if __name__ == '__main__':
    print(get_product('60f231605e0a4ea3c6c31c13'))
```

Recent changes
--------------

version 0.1.4

* add `MongoDocumentSchemator` and `MongoFieldSchemator`

version 0.1.3

* add `TransactionHelper`


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/frozflame/joker-mongodb",
    "name": "joker-mongodb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7.0",
    "maintainer_email": null,
    "keywords": null,
    "author": "frozflame",
    "author_email": "frozflame@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/85/fd/fdf3ddc3f4819fbf44bd9dd19d4469f0d3c4df7f45bd55e4e6a9a29b20cc/joker-mongodb-0.3.0.tar.gz",
    "platform": null,
    "description": "joker-mongodb\n=============\n\nAccess mongodb with handy utilities and fun.\n\n## Connnect to multiple mongo servers with MongoInterface\n\nExample:\n\n`GlobalInterface` is defined in `example/environ.py` as:\n\n```python\nfrom functools import cached_property\n\nimport volkanic\nfrom joker.mongodb.interfaces import MongoInterface\n\n\nclass GlobalInterface(volkanic.GlobalInterface):\n    package_name = 'example'\n    default_config = {\n        \"mongoi\": {\n            \"local\": {},\n            \"remote\": {\n                \"host\": \"192.168.22.122\",\n                \"port\": 27017\n            }\n        }\n    }\n\n    @cached_property\n    def mongoi(self) -> MongoInterface:\n        return MongoInterface.from_config(self.conf['mongoi'])\n```\n\nIf a configuration file is found at one of the follow locations:\n\n- Under your project directory in a development enviornment\n- `~/.example/config.json5`\n- `/etc/example/config.json5`\n- `/example/config.json5`\n\nit will override `GlobalInterface.default_config`.\n\nUsage in code `example/application.py`:\n\n```python\nfrom bson import ObjectId\n# noinspection PyUnresolvedReferences,PyPackageRequirements\nfrom example.environ import GlobalInterface\n\ngi = GlobalInterface()\n\n\ndef get_product(product_oid):\n    coll = gi.mongoi.get_coll('remote', 'example', 'products')\n    return coll.find_one({'_id': ObjectId(product_oid)})\n\n\nif __name__ == '__main__':\n    print(get_product('60f231605e0a4ea3c6c31c13'))\n```\n\nRecent changes\n--------------\n\nversion 0.1.4\n\n* add `MongoDocumentSchemator` and `MongoFieldSchemator`\n\nversion 0.1.3\n\n* add `TransactionHelper`\n\n",
    "bugtrack_url": null,
    "license": "GNU General Public License (GPL)",
    "summary": "access mongodb with handy utilities and fun",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/frozflame/joker-mongodb"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "85fdfdf3ddc3f4819fbf44bd9dd19d4469f0d3c4df7f45bd55e4e6a9a29b20cc",
                "md5": "f869ff780868ee7cdb8a67163b961fb9",
                "sha256": "3a1147dbbcd131f7858dbb060d0d74d92d1107ce85b6e4fe9eb0ea590098c4fe"
            },
            "downloads": -1,
            "filename": "joker-mongodb-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f869ff780868ee7cdb8a67163b961fb9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.0",
            "size": 27878,
            "upload_time": "2024-05-06T02:57:57",
            "upload_time_iso_8601": "2024-05-06T02:57:57.764124Z",
            "url": "https://files.pythonhosted.org/packages/85/fd/fdf3ddc3f4819fbf44bd9dd19d4469f0d3c4df7f45bd55e4e6a9a29b20cc/joker-mongodb-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-06 02:57:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "frozflame",
    "github_project": "joker-mongodb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "joker-cast",
            "specs": [
                [
                    ">=",
                    "0.5.0"
                ]
            ]
        },
        {
            "name": "joker-textmanip",
            "specs": [
                [
                    ">=",
                    "0.3.1"
                ]
            ]
        },
        {
            "name": "joker",
            "specs": [
                [
                    ">=",
                    "0.3.3"
                ]
            ]
        },
        {
            "name": "pymongo",
            "specs": [
                [
                    ">=",
                    "3.11.0"
                ]
            ]
        },
        {
            "name": "volkanic",
            "specs": [
                [
                    ">=",
                    "0.5.1"
                ]
            ]
        }
    ],
    "lcname": "joker-mongodb"
}
        
Elapsed time: 0.30620s