Skip to main content

library that simplifies MongoDB operations

Project description

MongoHelper Logo

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

License: MIT This library is licensed under the MIT License - see the LICENSE file for details.

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

mongo-utilities-0.1.3.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

mongo_utilities-0.1.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file mongo-utilities-0.1.3.tar.gz.

File metadata

  • Download URL: mongo-utilities-0.1.3.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for mongo-utilities-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e9916fcd86154d6846b389cc497040243ca9e310ba361a8888695ace93be9c54
MD5 f8a4a63fc88b9e7ff5bd025cd2e4c2a3
BLAKE2b-256 56d22cbc129ba1314da175b853a06a3f11195bb8c45cdc6bc906611691f43f7c

See more details on using hashes here.

File details

Details for the file mongo_utilities-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mongo_utilities-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1b453ae3cfbe057bb95c4b24a118871fb43fb6cb7bc435143d6264cf61cd1592
MD5 736f6786a611efed04227153ed45ebbe
BLAKE2b-256 4dc971b051f3992eb9a7e6057b51cb50126b2246d1ce0a5c800fd578d14e1055

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