Metadata-Version: 2.1
Name: py-easy-rest-mongo-motor-repo
Version: 0.1.3
Summary: Mongo repo to use with Py Easy REST
Author: Jean Pinzon
Author-email: jean.pinzon1@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: tests

![Lint](https://github.com/JeanPinzon/py-easy-rest-mongo-motor-repo/actions/workflows/python-lint.yml/badge.svg)
![Build and Test](https://github.com/JeanPinzon/py-easy-rest-mongo-motor-repo/actions/workflows/python-test.yml/badge.svg)
![Upload Package](https://github.com/JeanPinzon/py-easy-rest-mongo-motor-repo/actions/workflows/python-publish.yml/badge.svg)
[![PyPI version](https://badge.fury.io/py/py-easy-rest-mongo-motor-repo.svg)](https://badge.fury.io/py/py-easy-rest-mongo-motor-repo)

# py-easy-rest-mongo-motor-repo

Mongo repo to use with [py-easy-rest](https://github.com/JeanPinzon/py-easy-rest)


## Getting Started

### How to install

`pip install py-easy-rest py-easy-rest-mongo-motor-repo`


### Integrating with your [py-easy-rest](https://github.com/JeanPinzon/py-easy-rest) app


### Mongo Repository

```python
#main.py
from motor.motor_asyncio import AsyncIOMotorClient

from py_easy_rest.server import App
from py_easy_rest_mongo_motor_repo.mongo_motor_repo import MongoRepo


config = {
    "name": "Project Name",
    "schemas": [{
        "name": "Mock",
        "slug": "mock",
        "properties": {
            "name": {"type": "string"},
            "age": {"type": "integer"},
        },
        "required": ["name"],
    }]
}

repo = MongoRepo()

pyrApp = App(config, repo=repo)

@pyrApp.app.listener('before_server_start')
def init(app, loop):
    mongo_db_instance = AsyncIOMotorClient("mongodb://localhost:27017/db")
    db = mongo_db_instance.get_default_database()
    repo.set_db_connection(db)


pyrApp.app.run(
    host='0.0.0.0',
    port=8000,
    debug=True,
    auto_reload=True,
)
```


