mongotoy


Namemongotoy JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://gurcuff91.github.io/mongotoy
SummaryComprehensive ODM for MongoDB
upload_time2024-05-30 14:49:59
maintainerNone
docs_urlNone
authorgurcuff91
requires_python<4.0,>=3.12
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>Comprehensive 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">
  Mongotoy is a comprehensive Object-Document Mapper (ODM) that streamlines interactions with MongoDB databases in 
  Python applications. Powered by <a href="https://github.com/mongodb/motor">Motor</a> driver, Mongotoy seamlessly 
  integrates with MongoDB, offering a versatile toolkit for constructing high-performance applications. This integration
  facilitates efficient communication with MongoDB databases, guaranteeing optimal scalability and responsiveness. With 
  Mongotoy, you can unlock the full potential of MongoDB's features.
</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](https://github.com/mongodb/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.12",
    "maintainer_email": null,
    "keywords": "mapping, asyncio, odm, mongodb",
    "author": "gurcuff91",
    "author_email": "gf.meneses91@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/78/09/812d4a4a04b1bfebb890c4c079f04aef508c63074baa73c0a6507afde1f9/mongotoy-0.1.7.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>Comprehensive 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  Mongotoy is a comprehensive Object-Document Mapper (ODM) that streamlines interactions with MongoDB databases in \n  Python applications. Powered by <a href=\"https://github.com/mongodb/motor\">Motor</a> driver, Mongotoy seamlessly \n  integrates with MongoDB, offering a versatile toolkit for constructing high-performance applications. This integration\n  facilitates efficient communication with MongoDB databases, guaranteeing optimal scalability and responsiveness. With \n  Mongotoy, you can unlock the full potential of MongoDB's features.\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- **Based on Motor Driver**: Mongotoy is built on top of the asynchronous [Motor](https://github.com/mongodb/motor)\nMongoDB driver, ensuring seamless integration with asynchronous Python applications.\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- **Intuitive API**: Mongotoy features an elegant and straightforward API facilitating common database operations.\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- **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- **Object-Document Mapping**: Simplifying MongoDB document manipulation, Mongotoy maps Python objects to MongoDB \ndocuments seamlessly, enabling intuitive and object-oriented interactions.\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- **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- **Python Type Hint Support**: Mongotoy allows developers to define document fields using Python type hints, \nenhancing code readability and enabling type checking.\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- **Automatic Operation Handling**: Mongotoy automates insertion and deletion management, ensuring data integrity \nand consistency across related documents.\n\n- **Query Building**: Mongotoy provides a powerful query building interface for constructing complex queries using \nPythonic syntax.\n\n- **Index Management**: Mongotoy simplifies the management of database indexes, optimizing query performance for \nefficient data retrieval.\n\n- **Transactions**: Supporting MongoDB transactions, Mongotoy ensures data consistency and atomicity across multiple\noperations within a single transactional context.\n\n- **Geospatial Data Support**: Mongotoy offers robust support for geospatial data types, facilitating storage, \nquerying, and spatial analysis.\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- **Support for Capped Collections**: Mongotoy natively supports capped collections in MongoDB, ideal for \nscenarios requiring fixed-size, ordered datasets.\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- **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": "Comprehensive ODM for MongoDB",
    "version": "0.1.7",
    "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": "0a02b5c5440f20623f06fe06a119790da2aef8238a626950911f442c42bdb7da",
                "md5": "8403e1601a190400f25a3bedbe7357d3",
                "sha256": "53f142c46954bf300f853de955596e17e4f4a69afacb287cf7a57a2978a273fb"
            },
            "downloads": -1,
            "filename": "mongotoy-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8403e1601a190400f25a3bedbe7357d3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.12",
            "size": 40854,
            "upload_time": "2024-05-30T14:49:57",
            "upload_time_iso_8601": "2024-05-30T14:49:57.910965Z",
            "url": "https://files.pythonhosted.org/packages/0a/02/b5c5440f20623f06fe06a119790da2aef8238a626950911f442c42bdb7da/mongotoy-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7809812d4a4a04b1bfebb890c4c079f04aef508c63074baa73c0a6507afde1f9",
                "md5": "32a95474f2b7dac2cc937a998403a860",
                "sha256": "504cbb389a5d32852b4ac7549335aad86a96e158888e3d29036967cdd1b35df6"
            },
            "downloads": -1,
            "filename": "mongotoy-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "32a95474f2b7dac2cc937a998403a860",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.12",
            "size": 36405,
            "upload_time": "2024-05-30T14:49:59",
            "upload_time_iso_8601": "2024-05-30T14:49:59.060383Z",
            "url": "https://files.pythonhosted.org/packages/78/09/812d4a4a04b1bfebb890c4c079f04aef508c63074baa73c0a6507afde1f9/mongotoy-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-30 14:49:59",
    "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.24810s