# MongoRex
MongoRex is a powerful and easy-to-use Python library that simplifies MongoDB operations, providing a clean and reusable interface for CRUD, indexing, aggregation, and database management tasks. Whether you're building a small app or managing large-scale databases, MongoRex helps you interact with MongoDB effortlessly.
---
## 🚀 Features
- **CRUD Operations**: Simplify creating, reading, updating, and deleting MongoDB documents.
- **Index Management**: Efficiently create, drop, and list indexes to enhance performance.
- **Aggregation Pipeline**: Perform advanced queries using MongoDB’s aggregation framework.
- **Database Management**: Handle database and collection tasks with ease.
- **Transactions & Bulk Writes**: Streamline operations with session-based transactions and bulk write capabilities.
- **MapReduce**: Perform complex transformations and aggregations on data.
- **Distinct & Stats**: Get distinct values and gather database statistics.
- **Watch for Changes**: Monitor changes in collections or the entire database.
- **Server & Collection Stats**: Fetch detailed information about the server and individual collections.
---
## 📦 Installation
Install MongoRex using pip:
```bash
pip install mongorex
```
---
## 🛠️ Quick Start
Here’s how you can start using MongoRex in your Python application:
### 1. Initialize MongoRex
```python
from mongorex import DataBase
# Replace with your MongoDB URI and database name
mongo = DataBase(DB_Name="your_database", MongoURI="mongodb://localhost:27017")
```
### 2. Basic CRUD Operations
#### Add a Document
```python
document = {"name": "Alice", "age": 30}
mongo.add_doc("users", document)
```
#### Find Documents
```python
user = mongo.find_doc("users", {"name": "Alice"})
```
#### Update a Document
```python
mongo.update_doc("users", {"name": "Alice"}, {"age": 31})
```
#### Delete a Document
```python
mongo.delete_doc("users", {"name": "Alice"})
```
---
## 📚 Documentation
### **CRUD Operations**
- **add_doc(collection, document)**: Insert a single document into the specified collection.
- **add_docs(collection, documents)**: Insert multiple documents into the specified collection.
- **find_doc(collection, query)**: Retrieve a single document based on the query.
- **find_docs(collection, query)**: Retrieve multiple documents based on the query.
- **update_doc(collection, filter_query, update_data)**: Update a single document matching the filter.
- **update_docs(collection, filter_query, update_data)**: Update multiple documents matching the filter.
- **delete_doc(collection, query)**: Delete a single document matching the query.
- **delete_docs(collection, query)**: Delete multiple documents matching the query.
---
### **Aggregation**
- **aggregate(collection, pipeline)**: Perform advanced aggregation operations using MongoDB's aggregation pipeline.
---
### **Index Operations**
- **create_index(collection, keys, **kwargs)**: Create an index for the specified collection.
- **drop_index(collection, index_name)**: Drop an existing index from the collection.
- **list_indexes(collection)**: List all indexes for the given collection.
---
### **Collection & Database Management**
- **drop_collection(collection)**: Drop a collection from the database.
- **list_collections()**: List all collections in the database.
- **server_status()**: Retrieve the status of the MongoDB server.
- **db_stats()**: Get statistics about the database.
- **collection_stats(collection)**: Retrieve statistics for a specific collection.
---
### **Transactions & Bulk Write**
- **start_session()**: Start a new session for MongoDB transactions.
- **bulk_write(collection, operations)**: Perform bulk write operations on a collection.
---
### **Advanced Operations**
- **replace_doc(collection, filter_query, replacement)**: Replace a document with a new one.
- **distinct(collection, field, query=None)**: Retrieve distinct values for a specified field.
- **map_reduce(collection, map_function, reduce_function, out)**: Perform map-reduce operations on a collection.
- **rename_collection(old_name, new_name)**: Rename a collection.
- **watch(collection=None, pipeline=None)**: Watch for changes in a collection or the entire database.
---
### **Connection Management**
- **close_connection()**: Close the MongoDB connection safely.
---
## ⚙️ Requirements
- Python 3.6+
- pymongo library
To install required dependencies, simply run:
```bash
pip install pymongo
```
---
## 📝 License
MongoRex is licensed under the **CC-BY-SA 4.0** license. Feel free to use, modify, and share it, but make sure to give appropriate credit.
---
## 🏆 Contributors
MongoRex is developed and maintained by [TraxDinosaur](https://traxdinosaur.github.io). Contributions are welcome! Feel free to open an issue or create a pull request on [GitHub](https://github.com/TraxDinosaur/MongoRex).
---
## 🎯 Get Started Today
MongoRex simplifies the complexity of interacting with MongoDB. Whether you’re building a quick prototype or scaling a large system, MongoRex provides the tools you need to work with MongoDB databases efficiently.
Get started now and explore the full range of MongoRex capabilities!
Raw data
{
"_id": null,
"home_page": "https://github.com/TraxDinosaur/MongoRex",
"name": "MongoRex",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "MongoDB, Python MongoDB, MongoDB operations, CRUD operations, Database management, MongoDB Python package, MongoDB CRUD, MongoDB indexing, MongoDB aggregation, Database interface, MongoDB toolkit, Python database library, MongoRex",
"author": "TraxDinosaur",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/13/79/644dc314660c775346fe117cdb7c92849d9de83e1bc10c6b181cd072bd20/mongorex-1.0.0.tar.gz",
"platform": null,
"description": "# MongoRex\r\n\r\nMongoRex is a powerful and easy-to-use Python library that simplifies MongoDB operations, providing a clean and reusable interface for CRUD, indexing, aggregation, and database management tasks. Whether you're building a small app or managing large-scale databases, MongoRex helps you interact with MongoDB effortlessly.\r\n\r\n---\r\n\r\n## \ud83d\ude80 Features\r\n\r\n- **CRUD Operations**: Simplify creating, reading, updating, and deleting MongoDB documents.\r\n- **Index Management**: Efficiently create, drop, and list indexes to enhance performance.\r\n- **Aggregation Pipeline**: Perform advanced queries using MongoDB\u2019s aggregation framework.\r\n- **Database Management**: Handle database and collection tasks with ease.\r\n- **Transactions & Bulk Writes**: Streamline operations with session-based transactions and bulk write capabilities.\r\n- **MapReduce**: Perform complex transformations and aggregations on data.\r\n- **Distinct & Stats**: Get distinct values and gather database statistics.\r\n- **Watch for Changes**: Monitor changes in collections or the entire database.\r\n- **Server & Collection Stats**: Fetch detailed information about the server and individual collections.\r\n\r\n---\r\n\r\n## \ud83d\udce6 Installation\r\n\r\nInstall MongoRex using pip:\r\n\r\n```bash\r\npip install mongorex\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udee0\ufe0f Quick Start\r\n\r\nHere\u2019s how you can start using MongoRex in your Python application:\r\n\r\n### 1. Initialize MongoRex\r\n\r\n```python\r\nfrom mongorex import DataBase\r\n\r\n# Replace with your MongoDB URI and database name\r\nmongo = DataBase(DB_Name=\"your_database\", MongoURI=\"mongodb://localhost:27017\")\r\n```\r\n\r\n### 2. Basic CRUD Operations\r\n\r\n#### Add a Document\r\n\r\n```python\r\ndocument = {\"name\": \"Alice\", \"age\": 30}\r\nmongo.add_doc(\"users\", document)\r\n```\r\n\r\n#### Find Documents\r\n\r\n```python\r\nuser = mongo.find_doc(\"users\", {\"name\": \"Alice\"})\r\n```\r\n\r\n#### Update a Document\r\n\r\n```python\r\nmongo.update_doc(\"users\", {\"name\": \"Alice\"}, {\"age\": 31})\r\n```\r\n\r\n#### Delete a Document\r\n\r\n```python\r\nmongo.delete_doc(\"users\", {\"name\": \"Alice\"})\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udcda Documentation\r\n\r\n### **CRUD Operations**\r\n\r\n- **add_doc(collection, document)**: Insert a single document into the specified collection.\r\n- **add_docs(collection, documents)**: Insert multiple documents into the specified collection.\r\n- **find_doc(collection, query)**: Retrieve a single document based on the query.\r\n- **find_docs(collection, query)**: Retrieve multiple documents based on the query.\r\n- **update_doc(collection, filter_query, update_data)**: Update a single document matching the filter.\r\n- **update_docs(collection, filter_query, update_data)**: Update multiple documents matching the filter.\r\n- **delete_doc(collection, query)**: Delete a single document matching the query.\r\n- **delete_docs(collection, query)**: Delete multiple documents matching the query.\r\n\r\n---\r\n\r\n### **Aggregation**\r\n\r\n- **aggregate(collection, pipeline)**: Perform advanced aggregation operations using MongoDB's aggregation pipeline.\r\n\r\n---\r\n\r\n### **Index Operations**\r\n\r\n- **create_index(collection, keys, **kwargs)**: Create an index for the specified collection.\r\n- **drop_index(collection, index_name)**: Drop an existing index from the collection.\r\n- **list_indexes(collection)**: List all indexes for the given collection.\r\n\r\n---\r\n\r\n### **Collection & Database Management**\r\n\r\n- **drop_collection(collection)**: Drop a collection from the database.\r\n- **list_collections()**: List all collections in the database.\r\n- **server_status()**: Retrieve the status of the MongoDB server.\r\n- **db_stats()**: Get statistics about the database.\r\n- **collection_stats(collection)**: Retrieve statistics for a specific collection.\r\n\r\n---\r\n\r\n### **Transactions & Bulk Write**\r\n\r\n- **start_session()**: Start a new session for MongoDB transactions.\r\n- **bulk_write(collection, operations)**: Perform bulk write operations on a collection.\r\n\r\n---\r\n\r\n### **Advanced Operations**\r\n\r\n- **replace_doc(collection, filter_query, replacement)**: Replace a document with a new one.\r\n- **distinct(collection, field, query=None)**: Retrieve distinct values for a specified field.\r\n- **map_reduce(collection, map_function, reduce_function, out)**: Perform map-reduce operations on a collection.\r\n- **rename_collection(old_name, new_name)**: Rename a collection.\r\n- **watch(collection=None, pipeline=None)**: Watch for changes in a collection or the entire database.\r\n\r\n---\r\n\r\n### **Connection Management**\r\n\r\n- **close_connection()**: Close the MongoDB connection safely.\r\n\r\n---\r\n\r\n## \u2699\ufe0f Requirements\r\n\r\n- Python 3.6+\r\n- pymongo library\r\n\r\nTo install required dependencies, simply run:\r\n\r\n```bash\r\npip install pymongo\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udcdd License\r\n\r\nMongoRex is licensed under the **CC-BY-SA 4.0** license. Feel free to use, modify, and share it, but make sure to give appropriate credit.\r\n\r\n---\r\n\r\n## \ud83c\udfc6 Contributors\r\n\r\nMongoRex is developed and maintained by [TraxDinosaur](https://traxdinosaur.github.io). Contributions are welcome! Feel free to open an issue or create a pull request on [GitHub](https://github.com/TraxDinosaur/MongoRex).\r\n\r\n---\r\n\r\n## \ud83c\udfaf Get Started Today\r\n\r\nMongoRex simplifies the complexity of interacting with MongoDB. Whether you\u2019re building a quick prototype or scaling a large system, MongoRex provides the tools you need to work with MongoDB databases efficiently.\r\n\r\nGet started now and explore the full range of MongoRex capabilities!\r\n",
"bugtrack_url": null,
"license": null,
"summary": "MongoRex simplifies MongoDB operations by providing a clean, reusable interface for CRUD, indexing, aggregation, and database management tasks.",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/TraxDinosaur/MongoRex"
},
"split_keywords": [
"mongodb",
" python mongodb",
" mongodb operations",
" crud operations",
" database management",
" mongodb python package",
" mongodb crud",
" mongodb indexing",
" mongodb aggregation",
" database interface",
" mongodb toolkit",
" python database library",
" mongorex"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6c0244e9b01c0ff914af2e268e4f7dbc6bf5fbc2b98cad2b69aba133f7867c81",
"md5": "7f4b984d733a16a140a99881b523dfbc",
"sha256": "4ed5cf06ecad7821c9e956e846baa7007632c2fc6b82eb3d8dc06e6c6046944b"
},
"downloads": -1,
"filename": "MongoRex-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7f4b984d733a16a140a99881b523dfbc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5336,
"upload_time": "2025-01-08T05:33:35",
"upload_time_iso_8601": "2025-01-08T05:33:35.866065Z",
"url": "https://files.pythonhosted.org/packages/6c/02/44e9b01c0ff914af2e268e4f7dbc6bf5fbc2b98cad2b69aba133f7867c81/MongoRex-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1379644dc314660c775346fe117cdb7c92849d9de83e1bc10c6b181cd072bd20",
"md5": "d393794293000eeb25a7463104f58ff2",
"sha256": "21421b7370d7f0ce4d3a24b6587d55566f6f4466058c60ebc0c7a07ea65c54eb"
},
"downloads": -1,
"filename": "mongorex-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "d393794293000eeb25a7463104f58ff2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5191,
"upload_time": "2025-01-08T05:33:38",
"upload_time_iso_8601": "2025-01-08T05:33:38.271484Z",
"url": "https://files.pythonhosted.org/packages/13/79/644dc314660c775346fe117cdb7c92849d9de83e1bc10c6b181cd072bd20/mongorex-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-08 05:33:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "TraxDinosaur",
"github_project": "MongoRex",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mongorex"
}