Metadata-Version: 2.1
Name: joker-mongodb
Version: 0.0.5
Summary: access mongodb with handy utilities and fun
Home-page: https://github.com/frozflame/joker-mongodb
Author: frozflame
Author-email: frozflame@outlook.com
License: GNU General Public License (GPL)
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Description-Content-Type: text/markdown
License-File: LICENSE

joker-mongodb
=============

Access mongodb with handy utilities and fun.

Example:

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

```python
import volkanic
from joker.mongodb import GIMixinMongoi


class GlobalInterface(volkanic.GlobalInterface, GIMixinMongoi):
    package_name = 'example'
```

Configuration file `config.json5`:

```json5
{
    "mongoi": {
        "local": {},
        "remote": {
            "host": "192.168.22.122",
            // default mongo port is 27017
            "port": 27018
        }
    }
}
```

This `config.json5` is at one of the follow locations:
- Under your project directory in a development enviornment
- `~/.example/config.json5`
- `/etc/example/config.json5`
- `/example/config.json5`

Usage in code `example/application.py`:

```python
from bson import ObjectId
from example.environ import GlobalInterface  # noqa

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'))

```


