python-mongorm


Namepython-mongorm JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/tomasvotava/mongorm
SummaryMongORM is an ORM (object relational mapping) wrapper using async library motor for MongoDB connection and pydantic for data definition and validation.
upload_time2023-03-26 13:14:09
maintainer
docs_urlNone
authorTomas Votava
requires_python>=3.10,<4.0
licenseMIT
keywords mongodb mongo orm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # MongORM

![MongORM](./banner.png)

`MongORM` is an ORM (object relational mapping) wrapper using async library motor for `MongoDB` connection and pydantic for data definition and validation.

**This module is a work in progress and API may change radically.**

`MongORM` uses [`pydantic`](https://docs.pydantic.dev/) for data validation
and [`motor`](https://www.mongodb.com/docs/drivers/motor/) for async MongoDB connection.

## Installation

Using PIP:

```console
pip install python-mongorm
```

Using poetry:

```console
poetry add python-mongorm
```

## Usage

### Create client

```python
from mongorm import MongORM

client = MongORM("mongodb://root:root@localhost:27017/", "database")
```

### Define model

```python
from mongorm import BaseModel, MongoIndex, MongoIndexType

class Book(BaseModel):
    """Define models the way you would define pydantic models"""

    class Meta:
        """Meta contains the model's configuration and indexes"""
        client = client  # pass the client to the model's Meta
        collection = "books"
        title = MongoIndex("title", MongoIndexType.ASCENDING)
        author = MongoIndex("author", MongoIndexType.ASCENDING)
    
    # id field of type ObjectId is created automatically
    title: str
    author: str
    year_published: int

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tomasvotava/mongorm",
    "name": "python-mongorm",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "mongodb,mongo,orm",
    "author": "Tomas Votava",
    "author_email": "info@tomasvotava.eu",
    "download_url": "https://files.pythonhosted.org/packages/3a/23/0a552d9ae0f771a994f842d6080a6f79c9c52af9d655bd1e2014bff6d8c6/python_mongorm-0.1.1.tar.gz",
    "platform": null,
    "description": "# MongORM\n\n![MongORM](./banner.png)\n\n`MongORM` is an ORM (object relational mapping) wrapper using async library motor for `MongoDB` connection and pydantic for data definition and validation.\n\n**This module is a work in progress and API may change radically.**\n\n`MongORM` uses [`pydantic`](https://docs.pydantic.dev/) for data validation\nand [`motor`](https://www.mongodb.com/docs/drivers/motor/) for async MongoDB connection.\n\n## Installation\n\nUsing PIP:\n\n```console\npip install python-mongorm\n```\n\nUsing poetry:\n\n```console\npoetry add python-mongorm\n```\n\n## Usage\n\n### Create client\n\n```python\nfrom mongorm import MongORM\n\nclient = MongORM(\"mongodb://root:root@localhost:27017/\", \"database\")\n```\n\n### Define model\n\n```python\nfrom mongorm import BaseModel, MongoIndex, MongoIndexType\n\nclass Book(BaseModel):\n    \"\"\"Define models the way you would define pydantic models\"\"\"\n\n    class Meta:\n        \"\"\"Meta contains the model's configuration and indexes\"\"\"\n        client = client  # pass the client to the model's Meta\n        collection = \"books\"\n        title = MongoIndex(\"title\", MongoIndexType.ASCENDING)\n        author = MongoIndex(\"author\", MongoIndexType.ASCENDING)\n    \n    # id field of type ObjectId is created automatically\n    title: str\n    author: str\n    year_published: int\n\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "MongORM is an ORM (object relational mapping) wrapper using async library motor for MongoDB connection and pydantic for data definition and validation.",
    "version": "0.1.1",
    "split_keywords": [
        "mongodb",
        "mongo",
        "orm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ed40c16fc1c562a75dca5abe76cb7daf2c76b835502bf97bbdd3fbc87bc0d4eb",
                "md5": "7d4ea9fe4d776c9b4b3ff4442568061d",
                "sha256": "ed0e7f3aa723ac41818b622f6ca993bcc2dd157f584ac7bea0453b2f3c291cb1"
            },
            "downloads": -1,
            "filename": "python_mongorm-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7d4ea9fe4d776c9b4b3ff4442568061d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 7298,
            "upload_time": "2023-03-26T13:14:07",
            "upload_time_iso_8601": "2023-03-26T13:14:07.298735Z",
            "url": "https://files.pythonhosted.org/packages/ed/40/c16fc1c562a75dca5abe76cb7daf2c76b835502bf97bbdd3fbc87bc0d4eb/python_mongorm-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3a230a552d9ae0f771a994f842d6080a6f79c9c52af9d655bd1e2014bff6d8c6",
                "md5": "0bca6da144bc768b2810664647020a48",
                "sha256": "860328ead59386f17acf085c1efc491df0b7dba0e3e0d0085b347fcbab0989bc"
            },
            "downloads": -1,
            "filename": "python_mongorm-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0bca6da144bc768b2810664647020a48",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 6588,
            "upload_time": "2023-03-26T13:14:09",
            "upload_time_iso_8601": "2023-03-26T13:14:09.445719Z",
            "url": "https://files.pythonhosted.org/packages/3a/23/0a552d9ae0f771a994f842d6080a6f79c9c52af9d655bd1e2014bff6d8c6/python_mongorm-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-26 13:14:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "tomasvotava",
    "github_project": "mongorm",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "python-mongorm"
}
        
Elapsed time: 0.04990s