mongotoy


Namemongotoy JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://gurcuff91.github.io/mongotoy
SummaryAsync ODM for MongoDB
upload_time2024-04-07 21:22:50
maintainerNone
docs_urlNone
authorgurcuff91
requires_python<4.0,>=3.11
licenseApache-2.0
keywords mapping asyncio odm mongodb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <a href="https://github.com/gurcuff91/mongotoy">
    <img src="https://github.com/gurcuff91/mongotoy/blob/master/docs/assets/mongotoy.png" alt="Mongotoy Logo" width="45%" height="auto">
  </a>
</p>

<p align="center">
  <i>Async ODM for MongoDB.</i>
</p>

<p align="center">
  <a href="https://pypi.org/project/mongotoy/">
    <img src="https://img.shields.io/pypi/v/mongotoy?color=%2334D058&label=version" alt="Version"/>
  </a>
  <a href="https://pypi.org/project/mongotoy/">
    <img src="https://img.shields.io/pypi/pyversions/mongotoy.svg?color=%2334D058" alt="Supported Python Versions"/>
  </a>
</p>

<hr>
<p align="justify">
  <b>Mongotoy</b> is a comprehensive asynchronous Object-Document Mapper (ODM) designed to simplify interactions 
  with MongoDB databases in Python applications. Leveraging the Motor asynchronous MongoDB driver, Mongotoy 
  seamlessly integrates asynchronous programming with MongoDB, providing developers with a powerful toolset for 
  building high-performance applications. This integration allows for efficient communication with MongoDB databases,
  ensuring optimal scalability and responsiveness. With Mongotoy, developers can harness the full potential of 
  MongoDB's features while enjoying the benefits of asynchronous programming, making it an ideal choice for modern, 
  data-driven applications
</p>
<hr>

## Features

- **Asynchronous Power**: Mongotoy leverages the asynchronous paradigm of Python, enabling efficient management of
I/O operations for optimal performance and responsiveness in applications.


- **Based on Motor Driver**: Mongotoy is built on top of the asynchronous Motor MongoDB driver, ensuring seamless 
integration with asynchronous Python applications. 


- **Schemaless Flexibility**: With a schemaless design, Mongotoy empowers developers to work with MongoDB databases
without rigid schemas, adapting to evolving data models effortlessly.


- **Intuitive API**: Mongotoy features an elegant and straightforward API facilitating common database operations.


- **Flexible Configuration Options**: Mongotoy offers extensive configuration options at both the database and 
document levels, enabling fine-tuning of MongoDB interactions for optimal performance and reliability.


- **Custom Data Types Support**: Mongotoy simplifies handling of custom data types and allows defining new types
through Data Mapper classes, enhancing data integrity and consistency.


- **Object-Document Mapping**: Simplifying MongoDB document manipulation, Mongotoy maps Python objects to MongoDB 
documents seamlessly, enabling intuitive and object-oriented interactions.


- **Document Serialization**: Mongotoy supports serialization of documents into JSON, BSON, or Python dictionaries, 
enabling seamless integration with different parts of an application stack.


- **Document Inheritance Support**: Mongotoy provides robust support for document inheritance, enabling the creation
of hierarchical data models and promoting code reuse and maintainability.


- **Python Type Hint Support**: Mongotoy allows developers to define document fields using Python type hints, 
enhancing code readability and enabling type checking.


- **Relationship Management**: Simplifying relationship management between documents, Mongotoy offers robust support
for references and embedded documents, automating insertions, deletions, and updates.


- **Automatic Operation Handling**: Mongotoy automates insertion and deletion management, ensuring data integrity 
and consistency across related documents.


- **Query Building**: Mongotoy provides a powerful query building interface for constructing complex queries using 
Pythonic syntax.


- **Index Management**: Mongotoy simplifies the management of database indexes, optimizing query performance for 
efficient data retrieval.


- **Transactions**: Supporting MongoDB transactions, Mongotoy ensures data consistency and atomicity across multiple
operations within a single transactional context.


- **Geospatial Data Support**: Mongotoy offers robust support for geospatial data types, facilitating storage, 
querying, and spatial analysis.


- **Database Seeding Management**: With built-in support for database seeding, Mongotoy streamlines the 
initialization of databases with predefined data sets, enhancing developer productivity.


- **Support for Capped Collections**: Mongotoy natively supports capped collections in MongoDB, ideal for 
scenarios requiring fixed-size, ordered datasets.


- **Time Series Collections Management**: Mongotoy provides robust support for managing time series data in 
MongoDB, optimized for storing and querying time-stamped data points.


- **GridFS File Handling**: Mongotoy seamlessly integrates with MongoDB's GridFS storage system for efficient
handling of large files, offering a high-level interface for file management within MongoDB.

## Minimal Example
Let's begin with a minimal example by defining a document and performing CRUD operations on the database.

```python
import asyncio
from mongotoy import Document, Engine
import datetime


class Person(Document):
    name: str
    last_name: str
    dob: datetime.date

    
# Create database engine
db = Engine('test-db')


async def main():
    # Create a new Person instance
    person = Person(
        name='John',
        last_name='Doe',
        dob=datetime.date(1990, 12, 25)
    )    
    
    # Connect to the MongoDB database
    await db.connect('mongodb://localhost:27017')
    
    # Open a database session
    async with db.session() as session:
        
        # Save the person to the database
        await session.save(person)
        
        # Fetch all persons from database
        async for c in session.objects(Person):
            print(c.dump_dict())
            
        # Update person dob
        person.dob=datetime.date(1995, 10, 25)
        await session.save(person)
        
        # Delete person from database
        await session.delete(person)


if __name__ == '__main__':
    asyncio.run(main())
```

## Installing

 To install, just run:
 ```sh
 pip install mongotoy
 ```

Or, if using poetry:

```sh
poetry add mongotoy
```


## Extras
See full documentation at: https://gurcuff91.github.io/mongotoy

### If you like this project !!

<a href="https://www.buymeacoffee.com/gurcuff91"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="42" width="175"></a>

            

Raw data

            {
    "_id": null,
    "home_page": "https://gurcuff91.github.io/mongotoy",
    "name": "mongotoy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": "mapping, asyncio, odm, mongodb",
    "author": "gurcuff91",
    "author_email": "gf.meneses91@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/aa/aa/05373ed1cb291ec93ad68d04c0aea9d0610d757e28155caf489165760746/mongotoy-0.1.3.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <a href=\"https://github.com/gurcuff91/mongotoy\">\n    <img src=\"https://github.com/gurcuff91/mongotoy/blob/master/docs/assets/mongotoy.png\" alt=\"Mongotoy Logo\" width=\"45%\" height=\"auto\">\n  </a>\n</p>\n\n<p align=\"center\">\n  <i>Async ODM for MongoDB.</i>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://pypi.org/project/mongotoy/\">\n    <img src=\"https://img.shields.io/pypi/v/mongotoy?color=%2334D058&label=version\" alt=\"Version\"/>\n  </a>\n  <a href=\"https://pypi.org/project/mongotoy/\">\n    <img src=\"https://img.shields.io/pypi/pyversions/mongotoy.svg?color=%2334D058\" alt=\"Supported Python Versions\"/>\n  </a>\n</p>\n\n<hr>\n<p align=\"justify\">\n  <b>Mongotoy</b> is a comprehensive asynchronous Object-Document Mapper (ODM) designed to simplify interactions \n  with MongoDB databases in Python applications. Leveraging the Motor asynchronous MongoDB driver, Mongotoy \n  seamlessly integrates asynchronous programming with MongoDB, providing developers with a powerful toolset for \n  building high-performance applications. This integration allows for efficient communication with MongoDB databases,\n  ensuring optimal scalability and responsiveness. With Mongotoy, developers can harness the full potential of \n  MongoDB's features while enjoying the benefits of asynchronous programming, making it an ideal choice for modern, \n  data-driven applications\n</p>\n<hr>\n\n## Features\n\n- **Asynchronous Power**: Mongotoy leverages the asynchronous paradigm of Python, enabling efficient management of\nI/O operations for optimal performance and responsiveness in applications.\n\n\n- **Based on Motor Driver**: Mongotoy is built on top of the asynchronous Motor MongoDB driver, ensuring seamless \nintegration with asynchronous Python applications. \n\n\n- **Schemaless Flexibility**: With a schemaless design, Mongotoy empowers developers to work with MongoDB databases\nwithout rigid schemas, adapting to evolving data models effortlessly.\n\n\n- **Intuitive API**: Mongotoy features an elegant and straightforward API facilitating common database operations.\n\n\n- **Flexible Configuration Options**: Mongotoy offers extensive configuration options at both the database and \ndocument levels, enabling fine-tuning of MongoDB interactions for optimal performance and reliability.\n\n\n- **Custom Data Types Support**: Mongotoy simplifies handling of custom data types and allows defining new types\nthrough Data Mapper classes, enhancing data integrity and consistency.\n\n\n- **Object-Document Mapping**: Simplifying MongoDB document manipulation, Mongotoy maps Python objects to MongoDB \ndocuments seamlessly, enabling intuitive and object-oriented interactions.\n\n\n- **Document Serialization**: Mongotoy supports serialization of documents into JSON, BSON, or Python dictionaries, \nenabling seamless integration with different parts of an application stack.\n\n\n- **Document Inheritance Support**: Mongotoy provides robust support for document inheritance, enabling the creation\nof hierarchical data models and promoting code reuse and maintainability.\n\n\n- **Python Type Hint Support**: Mongotoy allows developers to define document fields using Python type hints, \nenhancing code readability and enabling type checking.\n\n\n- **Relationship Management**: Simplifying relationship management between documents, Mongotoy offers robust support\nfor references and embedded documents, automating insertions, deletions, and updates.\n\n\n- **Automatic Operation Handling**: Mongotoy automates insertion and deletion management, ensuring data integrity \nand consistency across related documents.\n\n\n- **Query Building**: Mongotoy provides a powerful query building interface for constructing complex queries using \nPythonic syntax.\n\n\n- **Index Management**: Mongotoy simplifies the management of database indexes, optimizing query performance for \nefficient data retrieval.\n\n\n- **Transactions**: Supporting MongoDB transactions, Mongotoy ensures data consistency and atomicity across multiple\noperations within a single transactional context.\n\n\n- **Geospatial Data Support**: Mongotoy offers robust support for geospatial data types, facilitating storage, \nquerying, and spatial analysis.\n\n\n- **Database Seeding Management**: With built-in support for database seeding, Mongotoy streamlines the \ninitialization of databases with predefined data sets, enhancing developer productivity.\n\n\n- **Support for Capped Collections**: Mongotoy natively supports capped collections in MongoDB, ideal for \nscenarios requiring fixed-size, ordered datasets.\n\n\n- **Time Series Collections Management**: Mongotoy provides robust support for managing time series data in \nMongoDB, optimized for storing and querying time-stamped data points.\n\n\n- **GridFS File Handling**: Mongotoy seamlessly integrates with MongoDB's GridFS storage system for efficient\nhandling of large files, offering a high-level interface for file management within MongoDB.\n\n## Minimal Example\nLet's begin with a minimal example by defining a document and performing CRUD operations on the database.\n\n```python\nimport asyncio\nfrom mongotoy import Document, Engine\nimport datetime\n\n\nclass Person(Document):\n    name: str\n    last_name: str\n    dob: datetime.date\n\n    \n# Create database engine\ndb = Engine('test-db')\n\n\nasync def main():\n    # Create a new Person instance\n    person = Person(\n        name='John',\n        last_name='Doe',\n        dob=datetime.date(1990, 12, 25)\n    )    \n    \n    # Connect to the MongoDB database\n    await db.connect('mongodb://localhost:27017')\n    \n    # Open a database session\n    async with db.session() as session:\n        \n        # Save the person to the database\n        await session.save(person)\n        \n        # Fetch all persons from database\n        async for c in session.objects(Person):\n            print(c.dump_dict())\n            \n        # Update person dob\n        person.dob=datetime.date(1995, 10, 25)\n        await session.save(person)\n        \n        # Delete person from database\n        await session.delete(person)\n\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\n## Installing\n\n To install, just run:\n ```sh\n pip install mongotoy\n ```\n\nOr, if using poetry:\n\n```sh\npoetry add mongotoy\n```\n\n\n## Extras\nSee full documentation at: https://gurcuff91.github.io/mongotoy\n\n### If you like this project !!\n\n<a href=\"https://www.buymeacoffee.com/gurcuff91\"><img src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"42\" width=\"175\"></a>\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Async ODM for MongoDB",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://gurcuff91.github.io/mongotoy",
        "Repository": "https://github.com/gurcuff91/mongotoy"
    },
    "split_keywords": [
        "mapping",
        " asyncio",
        " odm",
        " mongodb"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f3805895a9d7c5a55decf5260d1bb406387df325fb45553e660a723cdacf288",
                "md5": "d30f55832a5c761a6589d85c714bb958",
                "sha256": "fe01751e29e003bb999d700e091cb94cbcbcf5d45c6b9a3a4e8ae91c1b984849"
            },
            "downloads": -1,
            "filename": "mongotoy-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d30f55832a5c761a6589d85c714bb958",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 38753,
            "upload_time": "2024-04-07T21:22:49",
            "upload_time_iso_8601": "2024-04-07T21:22:49.177920Z",
            "url": "https://files.pythonhosted.org/packages/1f/38/05895a9d7c5a55decf5260d1bb406387df325fb45553e660a723cdacf288/mongotoy-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aaaa05373ed1cb291ec93ad68d04c0aea9d0610d757e28155caf489165760746",
                "md5": "771dd33b9ed75e54b2f3bf3e7edd0222",
                "sha256": "c843f7b3ee7f9c65fe3ab2033dd56dad6c7c57d85b4293332d4a9a07f4694684"
            },
            "downloads": -1,
            "filename": "mongotoy-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "771dd33b9ed75e54b2f3bf3e7edd0222",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 34639,
            "upload_time": "2024-04-07T21:22:50",
            "upload_time_iso_8601": "2024-04-07T21:22:50.457379Z",
            "url": "https://files.pythonhosted.org/packages/aa/aa/05373ed1cb291ec93ad68d04c0aea9d0610d757e28155caf489165760746/mongotoy-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-07 21:22:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gurcuff91",
    "github_project": "mongotoy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "mongotoy"
}
        
Elapsed time: 0.22774s