mongoapi


Namemongoapi JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/rekcah-pavi/mongoapi
SummaryA Python package for simplifying MongoDB operations with built-in support for TTL and CRUD functionality.
upload_time2024-11-18 12:02:42
maintainerNone
docs_urlNone
authorPaviththanan
requires_python>=3.6
licenseNone
keywords python mongodb api database management ttl crud operations pymongo
VCS
bugtrack_url
requirements httpx
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# MongoAPI

**MongoAPI** is a Python package designed to simplify MongoDB operations. This tool provides an intuitive interface for interacting with MongoDB collections, including features like CRUD operations, TTL (Time-To-Live) indexing, and automatic expiration handling.

<br>

## Installation

To install MongoAPI, use pip:

```bash
pip install mongoapi
```

or install directly from the GitHub repository:

```bash
pip install git+https://github.com/rekcah-pavi/mongoapi
```

---

## Features

- **CRUD Operations:** Easily perform Create, Read, Update, and Delete actions on MongoDB documents.
- **Expiration Handling:** Automatically manage document expiration with the `__expires` field.
- **Indexing:** Supports unique key indexing and TTL indexing for automatic cleanup of expired documents.
- **Lightweight Dependency:** Built with `pymongo` for efficient database interaction.

---

## Usage

### Initialize the API

```python
from mongoapi import mongoapi,mongodb_url

url = mongodb_url("username","pass","dbname","host") #port=27017
# Initialize the MongoAPI
api = mongoapi(url,"mydb")

```

### Insert or Update a Document

```python
# Insert or update a document
import time
ex = time.time()+60 #expires in 60 seconds
api.put({"key": "item1", "value": "data", "__expires": ex})  # __expires is an optional expiry timestamp

#insert many at once
api.put([{"key": https://pypi.org/project/mongoapi/
### Retrieve a Document

```python
# Retrieve  by key
item = api.get("item1")
print(item)
```

### Update Specific Fields

```python
# Update specific fields by key
api.patch("item1", {"value": "updated_data"})
```

### Delete a Document

```python
# Delete a document by key
api.delete("item1")
```

### Retrieve All Documents

```python
# Retrieve all non-expired documents
all_items = api.get_all()
print(all_items)
```

### Delete All Documents

```python
# Delete all documents in the collection
api.delete_all()
```

---

## License

This package is licensed under the MIT License. See the LICENSE file for details.

---

## Author

Developed by Paviththanan (rkpavi06@gmail.com).  
GitHub Repository: [MongoAPI](https://github.com/rekcah-pavi/mongoapi)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rekcah-pavi/mongoapi",
    "name": "mongoapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "Python, MongoDB, API, Database Management, TTL, CRUD Operations, pymongo",
    "author": "Paviththanan",
    "author_email": "rkpavi06@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/40/a4/39d35dcd98cab317710915efc7aa144b562ec4d73ef992926dc555096e13/mongoapi-1.0.2.tar.gz",
    "platform": null,
    "description": "\n# MongoAPI\n\n**MongoAPI** is a Python package designed to simplify MongoDB operations. This tool provides an intuitive interface for interacting with MongoDB collections, including features like CRUD operations, TTL (Time-To-Live) indexing, and automatic expiration handling.\n\n<br>\n\n## Installation\n\nTo install MongoAPI, use pip:\n\n```bash\npip install mongoapi\n```\n\nor install directly from the GitHub repository:\n\n```bash\npip install git+https://github.com/rekcah-pavi/mongoapi\n```\n\n---\n\n## Features\n\n- **CRUD Operations:** Easily perform Create, Read, Update, and Delete actions on MongoDB documents.\n- **Expiration Handling:** Automatically manage document expiration with the `__expires` field.\n- **Indexing:** Supports unique key indexing and TTL indexing for automatic cleanup of expired documents.\n- **Lightweight Dependency:** Built with `pymongo` for efficient database interaction.\n\n---\n\n## Usage\n\n### Initialize the API\n\n```python\nfrom mongoapi import mongoapi,mongodb_url\n\nurl = mongodb_url(\"username\",\"pass\",\"dbname\",\"host\") #port=27017\n# Initialize the MongoAPI\napi = mongoapi(url,\"mydb\")\n\n```\n\n### Insert or Update a Document\n\n```python\n# Insert or update a document\nimport time\nex = time.time()+60 #expires in 60 seconds\napi.put({\"key\": \"item1\", \"value\": \"data\", \"__expires\": ex})  # __expires is an optional expiry timestamp\n\n#insert many at once\napi.put([{\"key\": https://pypi.org/project/mongoapi/\n### Retrieve a Document\n\n```python\n# Retrieve  by key\nitem = api.get(\"item1\")\nprint(item)\n```\n\n### Update Specific Fields\n\n```python\n# Update specific fields by key\napi.patch(\"item1\", {\"value\": \"updated_data\"})\n```\n\n### Delete a Document\n\n```python\n# Delete a document by key\napi.delete(\"item1\")\n```\n\n### Retrieve All Documents\n\n```python\n# Retrieve all non-expired documents\nall_items = api.get_all()\nprint(all_items)\n```\n\n### Delete All Documents\n\n```python\n# Delete all documents in the collection\napi.delete_all()\n```\n\n---\n\n## License\n\nThis package is licensed under the MIT License. See the LICENSE file for details.\n\n---\n\n## Author\n\nDeveloped by Paviththanan (rkpavi06@gmail.com).  \nGitHub Repository: [MongoAPI](https://github.com/rekcah-pavi/mongoapi)\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python package for simplifying MongoDB operations with built-in support for TTL and CRUD functionality.",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/rekcah-pavi/mongoapi"
    },
    "split_keywords": [
        "python",
        " mongodb",
        " api",
        " database management",
        " ttl",
        " crud operations",
        " pymongo"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e11aec8171c0a2f39a50775c4bfe03abdede8edf08890ae4b0c5f4217b065d22",
                "md5": "e636bdd0c3637d017c42d192a410a525",
                "sha256": "d5eaebeac10b4c82a6c60564b3eed66e361da87e7c3f0bc8735be07fca2a1eb8"
            },
            "downloads": -1,
            "filename": "mongoapi-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e636bdd0c3637d017c42d192a410a525",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 4415,
            "upload_time": "2024-11-18T12:02:41",
            "upload_time_iso_8601": "2024-11-18T12:02:41.701900Z",
            "url": "https://files.pythonhosted.org/packages/e1/1a/ec8171c0a2f39a50775c4bfe03abdede8edf08890ae4b0c5f4217b065d22/mongoapi-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "40a439d35dcd98cab317710915efc7aa144b562ec4d73ef992926dc555096e13",
                "md5": "41e45e893b060ed678ce6b21bdb26403",
                "sha256": "ca2c7c30ef27f6f06692e7be9116c53fee5f9a06640f1dfff852363b7cac3610"
            },
            "downloads": -1,
            "filename": "mongoapi-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "41e45e893b060ed678ce6b21bdb26403",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4176,
            "upload_time": "2024-11-18T12:02:42",
            "upload_time_iso_8601": "2024-11-18T12:02:42.456959Z",
            "url": "https://files.pythonhosted.org/packages/40/a4/39d35dcd98cab317710915efc7aa144b562ec4d73ef992926dc555096e13/mongoapi-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-18 12:02:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rekcah-pavi",
    "github_project": "mongoapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "httpx",
            "specs": []
        }
    ],
    "lcname": "mongoapi"
}
        
Elapsed time: 0.84747s