bunnet


Namebunnet JSON
Version 1.2.0 PyPI version JSON
download
home_pageNone
SummarySynchronous Python ODM for MongoDB
upload_time2023-10-14 23:03:40
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7,<4.0
licenseNone
keywords mongodb odm orm pydantic mongo async python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![shields badge](https://shields.io/badge/-docs-blue)](https://roman-right.github.io/bunnet/)
[![pypi](https://img.shields.io/pypi/v/bunnet.svg)](https://pypi.python.org/pypi/bunnet)

[![Bunnet](https://github.com/roman-right/bunnet/raw/main/docs/assets/1.png)](https://github.com/roman-right/bunnet)

*The logo is generated by [WOMBO Dream](https://www.wombo.art)*

## Overview

[Bunnet](https://github.com/roman-right/bunnet) - is a Python object-document mapper (ODM) for MongoDB. It is a synchronous fork of [Beanie ODM](https://github.com/roman-right/beanie).

When using Bunnet each database collection has a corresponding `Document` that
is used to interact with that collection. In addition to retrieving data,
Bunnet allows you to add, update, or delete documents from the collection as
well.

Bunnet saves you time by removing boilerplate code, and it helps you focus on
the parts of your app that actually matter.

## Installation

### PIP

```shell
pip install bunnet
```

### Poetry

```shell
poetry add bunnet
```
## Example

```python
from typing import Optional

from pymongo import MongoClient
from pydantic import BaseModel

from bunnet import Document, Indexed, init_bunnet


class Category(BaseModel):
    name: str
    description: str


class Product(Document):
    name: str                          # You can use normal types just like in pydantic
    description: Optional[str] = None
    price: Indexed(float)              # You can also specify that a field should correspond to an index
    category: Category                 # You can include pydantic models as well



# Bunnet uses Pymongo client under the hood 
client = MongoClient("mongodb://user:pass@host:27017")

# Initialize bunnet with the Product document class
init_bunnet(database=client.db_name, document_models=[Product])

chocolate = Category(name="Chocolate", description="A preparation of roasted and ground cacao seeds.")
# Bunnet documents work just like pydantic models
tonybar = Product(name="Tony's", price=5.95, category=chocolate)
# And can be inserted into the database
tonybar.insert() 

# You can find documents with pythonic syntax
product = Product.find_one(Product.price < 10).run()

# And update them
product.set({Product.name:"Gold bar"})

```

## Links

### Documentation

- **[Doc](https://roman-right.github.io/bunnet/)** - Tutorial, API documentation, and development guidelines.

### Resources

- **[GitHub](https://github.com/roman-right/bunnet)** - GitHub page of the
  project
- **[Changelog](https://roman-right.github.io/bunnet/changelog)** - list of all
  the valuable changes
- **[Discord](https://discord.gg/29mMrEBvr4)** - ask your questions, share
  ideas or just say `Hello!!`

----
Supported by [JetBrains](https://jb.gg/OpenSource)

[![JetBrains](https://raw.githubusercontent.com/roman-right/beanie/main/assets/logo/jetbrains.svg)](https://jb.gg/OpenSource)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bunnet",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": null,
    "keywords": "mongodb,odm,orm,pydantic,mongo,async,python",
    "author": null,
    "author_email": "Roman Right <roman-right@protonmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b5/29/fd4783b53848c86efd657bac050e3560a443f7449fbf0a504a2be371b50c/bunnet-1.2.0.tar.gz",
    "platform": null,
    "description": "[![shields badge](https://shields.io/badge/-docs-blue)](https://roman-right.github.io/bunnet/)\n[![pypi](https://img.shields.io/pypi/v/bunnet.svg)](https://pypi.python.org/pypi/bunnet)\n\n[![Bunnet](https://github.com/roman-right/bunnet/raw/main/docs/assets/1.png)](https://github.com/roman-right/bunnet)\n\n*The logo is generated by [WOMBO Dream](https://www.wombo.art)*\n\n## Overview\n\n[Bunnet](https://github.com/roman-right/bunnet) - is a Python object-document mapper (ODM) for MongoDB. It is a synchronous fork of [Beanie ODM](https://github.com/roman-right/beanie).\n\nWhen using Bunnet each database collection has a corresponding `Document` that\nis used to interact with that collection. In addition to retrieving data,\nBunnet allows you to add, update, or delete documents from the collection as\nwell.\n\nBunnet saves you time by removing boilerplate code, and it helps you focus on\nthe parts of your app that actually matter.\n\n## Installation\n\n### PIP\n\n```shell\npip install bunnet\n```\n\n### Poetry\n\n```shell\npoetry add bunnet\n```\n## Example\n\n```python\nfrom typing import Optional\n\nfrom pymongo import MongoClient\nfrom pydantic import BaseModel\n\nfrom bunnet import Document, Indexed, init_bunnet\n\n\nclass Category(BaseModel):\n    name: str\n    description: str\n\n\nclass Product(Document):\n    name: str                          # You can use normal types just like in pydantic\n    description: Optional[str] = None\n    price: Indexed(float)              # You can also specify that a field should correspond to an index\n    category: Category                 # You can include pydantic models as well\n\n\n\n# Bunnet uses Pymongo client under the hood \nclient = MongoClient(\"mongodb://user:pass@host:27017\")\n\n# Initialize bunnet with the Product document class\ninit_bunnet(database=client.db_name, document_models=[Product])\n\nchocolate = Category(name=\"Chocolate\", description=\"A preparation of roasted and ground cacao seeds.\")\n# Bunnet documents work just like pydantic models\ntonybar = Product(name=\"Tony's\", price=5.95, category=chocolate)\n# And can be inserted into the database\ntonybar.insert() \n\n# You can find documents with pythonic syntax\nproduct = Product.find_one(Product.price < 10).run()\n\n# And update them\nproduct.set({Product.name:\"Gold bar\"})\n\n```\n\n## Links\n\n### Documentation\n\n- **[Doc](https://roman-right.github.io/bunnet/)** - Tutorial, API documentation, and development guidelines.\n\n### Resources\n\n- **[GitHub](https://github.com/roman-right/bunnet)** - GitHub page of the\n  project\n- **[Changelog](https://roman-right.github.io/bunnet/changelog)** - list of all\n  the valuable changes\n- **[Discord](https://discord.gg/29mMrEBvr4)** - ask your questions, share\n  ideas or just say `Hello!!`\n\n----\nSupported by [JetBrains](https://jb.gg/OpenSource)\n\n[![JetBrains](https://raw.githubusercontent.com/roman-right/beanie/main/assets/logo/jetbrains.svg)](https://jb.gg/OpenSource)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Synchronous Python ODM for MongoDB",
    "version": "1.2.0",
    "project_urls": {
        "homepage": "https://beanie-odm.dev",
        "repository": "https://github.com/roman-right/beanie"
    },
    "split_keywords": [
        "mongodb",
        "odm",
        "orm",
        "pydantic",
        "mongo",
        "async",
        "python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cdb79c28505631bc053190157e4ea07e55899efdf619252fe219f72e93b6418b",
                "md5": "571cefa37cc9cf4553270f4383986410",
                "sha256": "0c13511fc33a109ebaaa8aed0ff4488c2f553d97a3a521c02a2346d16dc79270"
            },
            "downloads": -1,
            "filename": "bunnet-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "571cefa37cc9cf4553270f4383986410",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 77796,
            "upload_time": "2023-10-14T23:03:39",
            "upload_time_iso_8601": "2023-10-14T23:03:39.012179Z",
            "url": "https://files.pythonhosted.org/packages/cd/b7/9c28505631bc053190157e4ea07e55899efdf619252fe219f72e93b6418b/bunnet-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b529fd4783b53848c86efd657bac050e3560a443f7449fbf0a504a2be371b50c",
                "md5": "0ae225dfd4b48786ea01d2c330e4fe44",
                "sha256": "8be5a58afa9a42c2af9913bfd264322806f20ca741ba488ea88e5f613ae42782"
            },
            "downloads": -1,
            "filename": "bunnet-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0ae225dfd4b48786ea01d2c330e4fe44",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 1643788,
            "upload_time": "2023-10-14T23:03:40",
            "upload_time_iso_8601": "2023-10-14T23:03:40.973460Z",
            "url": "https://files.pythonhosted.org/packages/b5/29/fd4783b53848c86efd657bac050e3560a443f7449fbf0a504a2be371b50c/bunnet-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-14 23:03:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "roman-right",
    "github_project": "beanie",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "bunnet"
}
        
Elapsed time: 0.16625s