library that simplifies MongoDB operations
Project description
Mongo Utilities
Introduction
MongoUtilities is a Python library that simplifies MongoDB operations by providing a convenient interface for common tasks.
Installation
pip install mongo-utilities
Usage
Make sure to set the following environment variables:
MONGO_DATABASE_URI: Your MongoDB database URI.
MONGO_DATABASE_NAME: Your MongoDB database name.
Then import it in you project
from mongo_helper import MongoUtilities
Initialize MongoHelper
mongo_helper = MongoUtilities(collection='your_collection', model=YourModelClass)
Insert data
mongo_helper.insert({'key': 'value'})
Find a document
document = mongo_helper.find_one_by(find_by=yourKey, value=yourValue)
Find a document Greater Than
documents = mongo_helper.find_greater_than(find_by=yourKey, greater_than=yourValue,greater_or_equal=False)
Find a document Less Than
documents = mongo_helper.find_greater_than(find_by=yourKey, less_than=yourValue,less_or_equal=False)
Find a document Return Only Specific Fields
documents = mongo_helper.find_specific_fields(find_by=yourKey, equal_to=yourValue,selected_field=['key1','key2'])
Find a documents Return as Model Objects
documents = mongo_helper.query()
Update a document
mongo_helper.update_one_doc('key', 'value', new_key='new_value')
Delete a document
mongo_helper.delete_one_doc('key', 'value')
License
This library is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mongo-utilities-0.1.4.tar.gz.
File metadata
- Download URL: mongo-utilities-0.1.4.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00887add7336f489eb8b150e43d19d041ced82fc99d4c2920536f1abe29c0648
|
|
| MD5 |
bad8a344369891fa99046fa08f91df0e
|
|
| BLAKE2b-256 |
b9cd86d3e186b5a5bbada89595bb15cc4af73dd6937c2da4552527b4f473f556
|
File details
Details for the file mongo_utilities-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mongo_utilities-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47cfe1ed046706c871c34486c4202c683cb0457442fd5b5a2dfa6cb469c2f7e9
|
|
| MD5 |
f0bb50834b2d5273f5da39923512637d
|
|
| BLAKE2b-256 |
e11624f6995c773917a08109d795977dcc59bbf2016d3d1089c9b93ae4327cb9
|