# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['beanie']

package_data = \
{'': ['*']}

install_requires = \
['motor>=2.1.0,<3.0.0', 'pydantic>=1.5.1,<2.0.0']

setup_kwargs = {
    'name': 'beanie',
    'version': '0.2.3',
    'description': 'MongoDB ODM based on Pydantic and Motor',
    'long_description': '.. image:: https://raw.githubusercontent.com/roman-right/beanie/main/assets/logo/with_text.svg\n\nBeanie - is an asynchronous ODM for MongoDB, based on `Motor <https://motor.readthedocs.io/en/stable/>`_ and `Pydantic <https://pydantic-docs.helpmanual.io/>`_.\n\nIt uses an abstraction over Pydantic models and Motor collections to work with the database. Class Document allows to create, replace, update, get, find and aggregate.\n\nHere you can see, how to use Beanie, in simple examples:\n\n============\nInstallation\n============\n\n----\nPIP\n----\n\n.. code-block:: bash\n\n    pip install beanie\n\n\n------\nPoetry\n------\n\n.. code-block:: bash\n\n    poetry add beanie\n\n============\nUsage\n============\n\n-----\nInit\n-----\n\n.. code-block:: python\n\n    from typing import List\n\n    import motor\n    from beanie import Document\n    from pydantic import BaseModel\n\n\n    # CREATE BEANIE DOCUMENT STRUCTURE\n\n    class SubDocument(BaseModel):\n        test_str: str\n\n\n    class DocumentTestModel(Document):\n        test_int: int\n        test_list: List[SubDocument]\n        test_str: str\n\n\n    # CREATE MOTOR CLIENT AND DB\n\n    client = motor.motor_asyncio.AsyncIOMotorClient(\n        "mongodb://user:pass@host:27017/db",\n        serverSelectionTimeoutMS=100\n    )\n    db = client.beanie_db\n\n    # INIT BEANIE\n\n    init_beanie(database=db, document_models=[DocumentTestModel])\n\n---------\nCreate\n---------\n\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nCreate a document (insert it)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    document = DocumentTestModel(\n        test_int=42,\n        test_list=[SubDocument(test_str="foo"), SubDocument(test_str="bar")],\n        test_str="kipasa",\n    )\n\n    await document.create()\n\n^^^^^^^^^^^^^^^^^^^\nInsert one document\n^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    document = DocumentTestModel(\n        test_int=42,\n        test_list=[SubDocument(test_str="foo"), SubDocument(test_str="bar")],\n        test_str="kipasa",\n    )\n\n    await DocumentTestModel.insert_one(document)\n\n^^^^^^^^^^^^^^^^^^^^^\nInsert many documents\n^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    document_1 = DocumentTestModel(\n        test_int=42,\n        test_list=[SubDocument(test_str="foo"), SubDocument(test_str="bar")],\n        test_str="kipasa",\n    )\n    document_2 = DocumentTestModel(\n        test_int=42,\n        test_list=[SubDocument(test_str="foo"), SubDocument(test_str="bar")],\n        test_str="kipasa",\n    )\n\n    await DocumentTestModel.insert_many([document_1, document_2])\n\n----\nFind\n----\n\n^^^^^^^^^^^^^^^^\nGet the document\n^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    document = await DocumentTestModel.get(DOCUMENT_ID)\n\n^^^^^^^^^^^^^^^^^\nFind one document\n^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    document = await DocumentTestModel.find_one({"test_str": "kipasa"})\n\n^^^^^^^^^^^^^^^^^^^\nFind many documents\n^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    async for document in DocumentTestModel.find_many({"test_str": "uno"}):\n        print(document)\n\nOR\n\n.. code-block:: python\n\n    documents =  await DocumentTestModel.find_many({"test_str": "uno"}).to_list()\n\n^^^^^^^^^^^^^^^^^^^^^^\nFind all the documents\n^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    async for document in DocumentTestModel.find_all()\n        print(document)\n\nOR\n\n.. code-block:: python\n\n    documents = await DocumentTestModel.find_all().to_list()\n\n------\nUpdate\n------\n\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nReplace the document (full update)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    document.test_str = "REPLACED_VALUE"\n    await document.replace()\n\n^^^^^^^^^^^^^^^^^^^^\nReplace one document\n^^^^^^^^^^^^^^^^^^^^\n\nReplace one doc data by another\n\n.. code-block:: python\n\n    new_doc = DocumentTestModel(\n        test_int=0,\n        test_str=\'REPLACED_VALUE\',\n        test_list=[]\n    )\n    await DocumentTestModel.replace_one({"_id": document.id}, new_doc)\n\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nUpdate the document (partial update)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nin this example, I\'ll add an item to the document\'s "test_list" field\n\n.. code-block:: python\n\n    to_insert = SubDocument(test_str="test")\n    await document.update(update_query={"$push": {"test_list": to_insert.dict()}})\n\n^^^^^^^^^^^^^^^^^^^\nUpdate one document\n^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    await DocumentTestModel.update_one(\n        update_query={"$set": {"test_list.$.test_str": "foo_foo"}},\n        filter_query={"_id": document.id, "test_list.test_str": "foo"},\n    )\n\n^^^^^^^^^^^^^^^^^^^^^\nUpdate many documents\n^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    await DocumentTestModel.update_many(\n        update_query={"$set": {"test_str": "bar"}},\n        filter_query={"test_str": "foo"},\n    )\n\n^^^^^^^^^^^^^^^^^^^^^^^^\nUpdate all the documents\n^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    await DocumentTestModel.update_all(\n        update_query={"$set": {"test_str": "bar"}}\n    )\n\n\n------\nDelete\n------\n\n^^^^^^^^^^^^^^^^^^^\nDelete the document\n^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    await document.delete()\n\n^^^^^^^^^^^^^^^^^^^^\nDelete one documents\n^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    await DocumentTestModel.delete_one({"test_str": "uno"})\n\n^^^^^^^^^^^^^^^^^^^^^\nDelete many documents\n^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    await DocumentTestModel.delete_many({"test_str": "dos"})\n\n^^^^^^^^^^^^^^^^^^^^^^^^\nDelete all the documents\n^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n    await DocumentTestModel.delete_all()\n\n\n---------\nAggregate\n---------\n\n\n.. code-block:: python\n\n    async for item in DocumentTestModel.aggregate(\n        [{"$group": {"_id": "$test_str", "total": {"$sum": "$test_int"}}}]\n    ):\n        print(item)\n\nOR\n\n.. code-block:: python\n\n    class OutputItem(BaseModel):\n        id: str = Field(None, alias="_id")\n        total: int\n\n    async for item in DocumentTestModel.aggregate(\n        [{"$group": {"_id": "$test_str", "total": {"$sum": "$test_int"}}}],\n        item_model=OutputModel\n    ):\n        print(item)\n\nOR\n\n.. code-block:: python\n\n    results = await DocumentTestModel.aggregate(\n        [{"$group": {"_id": "$test_str", "total": {"$sum": "$test_int"}}}],\n        item_model=OutputModel\n    ).to_list()',
    'author': 'Roman',
    'author_email': 'roman-right@protonmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/roman-right/beanie',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
