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.4.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.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

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

Hashes for mongo-utilities-0.1.4.tar.gz
Algorithm Hash digest
SHA256 00887add7336f489eb8b150e43d19d041ced82fc99d4c2920536f1abe29c0648
MD5 bad8a344369891fa99046fa08f91df0e
BLAKE2b-256 b9cd86d3e186b5a5bbada89595bb15cc4af73dd6937c2da4552527b4f473f556

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mongo_utilities-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 47cfe1ed046706c871c34486c4202c683cb0457442fd5b5a2dfa6cb469c2f7e9
MD5 f0bb50834b2d5273f5da39923512637d
BLAKE2b-256 e11624f6995c773917a08109d795977dcc59bbf2016d3d1089c9b93ae4327cb9

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