Skip to main content

MongoRex simplifies MongoDB operations by providing a clean, reusable interface for CRUD, indexing, aggregation, and database management tasks.

Project description

MongoRex ๐Ÿฆ–

MongoRex is a powerful and easy-to-use Python library that simplifies MongoDB operations. It provides a clean and reusable interface for CRUD operations, indexing, aggregation, transactions, and database management tasks.

Whether you're building a small app or managing large-scale databases, MongoRex makes working with MongoDB effortless.


๐Ÿš€ Features

โœ… Simple CRUD Operations โ€“ Easily create, read, update, and delete MongoDB documents.
โœ… Index Management โ€“ Efficiently create, drop, and list indexes to enhance performance.
โœ… Aggregation Pipeline โ€“ Perform advanced queries using MongoDBโ€™s aggregation framework.
โœ… Transaction Support โ€“ Manage multi-document transactions for data integrity.
โœ… Bulk Write Support โ€“ Streamline operations with batch updates and inserts.
โœ… Regex Search โ€“ Perform advanced text-based searches with regex support.
โœ… Get Latest Documents โ€“ Fetch the most recent N documents quickly.
โœ… Watch for Changes โ€“ Monitor real-time updates in collections.
โœ… Database & Collection Stats โ€“ Get insights on storage, indexes, and performance.
โœ… MapReduce Operations โ€“ Execute powerful data transformations and aggregations.
โœ… Connection Management โ€“ Safely handle and close MongoDB connections.


๐Ÿ“ฆ Installation

Install MongoRex using pip:

pip install MongoRex

Or, install from GitHub (latest version):

pip install git+https://github.com/TraxDinosaur/MongoRex.git

๐Ÿ› ๏ธ Quick Start

Hereโ€™s how you can start using MongoRex in your Python application:

1. Initialize MongoRex

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

document = {"name": "Alice", "age": 30}
mongo.add_doc("users", document)

๐Ÿ” Find a Document

user = mongo.find_doc("users", {"name": "Alice"})
print(user)

๐Ÿ”„ Update a Document

mongo.update_doc("users", {"name": "Alice"}, {"age": 31})

โŒ Delete a Document

mongo.delete_doc("users", {"name": "Alice"})

๐Ÿ“š Full API Reference

๐Ÿ“ CRUD Operations

Method Description
add_doc(collection, document) Insert a single document into a collection.
add_docs(collection, documents) Insert multiple documents into a collection.
find_doc(collection, query) Retrieve a single document matching the query.
find_docs(collection, query, regex_fields=None) Retrieve multiple documents with optional regex search.
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.
update_field(collection, filter_query, field, value) Update a single field in a document.
delete_doc(collection, query) Delete a single document matching the query.
delete_docs(collection, query) Delete multiple documents matching the query.
delete_all(collection) Delete all documents in a collection.

๐Ÿ“Š Aggregation & Querying

Method Description
aggregate(collection, pipeline) Perform advanced aggregation operations.
get_latest(collection, limit=5, sort_field="_id") Fetch the latest N documents sorted by a field.
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 data.

โšก Index Management

Method Description
create_index(collection, keys, **kwargs) Create an index for a collection.
drop_index(collection, index_name) Drop an existing index.
list_indexes(collection) List all indexes in a collection.

๐Ÿ“ Database & Collection Management

Method Description
drop_collection(collection) Drop a collection from the database.
list_collections() List all collections in the database.
server_status() Retrieve MongoDB server status.
db_stats() Get database statistics.
collection_stats(collection) Retrieve collection statistics.

๐Ÿ”„ Transactions & Bulk Operations

Method Description
start_session() Start a MongoDB transaction session.
bulk_write(collection, operations) Perform bulk write operations.

๐Ÿ‘€ Watch for Changes

Method Description
watch(collection=None, pipeline=None) Monitor changes in a collection or database.

๐Ÿ”„ Advanced Document Operations

Method Description
replace_doc(collection, filter_query, replacement) Replace a document with a new one.
rename_collection(old_name, new_name) Rename a collection.

๐Ÿ”Œ Connection Management

Method Description
close_connection() Close the MongoDB connection safely.

โš™๏ธ Requirements

  • Python 3.6+
  • pymongo library

Install dependencies manually if needed:

pip install pymongo

๐Ÿ›ก๏ธ License

MongoRex is licensed under the CC-BY-SA 4.0 license. Feel free to use, modify, and share it, but give appropriate credit.


๐Ÿ† Contributors

MongoRex is developed and maintained by TraxDinosaur.

๐Ÿš€ Contributions are welcome! Feel free to open an issue or submit a pull request on GitHub.


๐ŸŽฏ Get Started Today!

MongoRex simplifies MongoDB operations so you can focus on building great applications.

Start using MongoRex today and enhance your database management experience! ๐Ÿš€

๐Ÿ“Œ GitHub Repository: MongoRex on GitHub

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mongorex-1.0.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

MongoRex-1.0.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file mongorex-1.0.3.tar.gz.

File metadata

  • Download URL: mongorex-1.0.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for mongorex-1.0.3.tar.gz
Algorithm Hash digest
SHA256 5610823c3f35ed6af8a787ebee652f1a2ca32004aab5135c319cb5ae0ec15ef7
MD5 08eebab23b447e92c80513e6a1adefbb
BLAKE2b-256 93b7c6074a1b59bdec71451e31e9365523f7a535dc5596037e5987786e0232a9

See more details on using hashes here.

File details

Details for the file MongoRex-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: MongoRex-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for MongoRex-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6ff5a39403e6d74c9acfdf4bbb10cdb5076dd51003ad7dc1b3bfc61bcffba6dd
MD5 ab36858ace2b46091a4c7cbe6cac8abf
BLAKE2b-256 08369fe89bb3b1021fc7e897ac91dae287d29f60d421fe6fbb3b87ea60b5d1af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page