Few lines describing your project.
This Python Package called PyMongo Wrapper wrapp the Pymongo python package for projects which are schemaless
PyMongo Wrapper provides a simple wrapper around pymongo which is providing CRUD functionality on the MongoDB when we don't have Schema (Schemaless)
What things you need to install the software and how to install them.
git clone https://github.com/Mdevpro78/pymongo-wrapper.git
A step by step series to install the package
cd pymongo-wrapper
python setup.py install
or just
pip install .
from repository import DBRepository
collection_name = 'my_collection'
database_name = 'my_database'
uri = 'mongodb://localhost:27017/'
db_repo = DBRepository(collection_name, database_name, uri)
# Instantiate the pipeline builder
builder = PipelineBuilder()
# Add a $match stage
builder.match({'name': 'John'})
# Add a $project stage
builder.project({'name': 1, 'age': 1})
# Add a $group stage
builder.group(['name'], count={'$sum': 1})
# Add a $sort stage
builder.sort([('count', -1), ('name', 1)])
# Add a $skip stage
builder.skip(10)
# Add a $limit stage
builder.limit(5)
# Add a $unwind stage
builder.unwind('$tags')
# Build the pipeline
pipeline = builder.build()
# Example usage of query_repo()
query_repo = db_repo.query_repo()
results = query_repo.aggregate(pipeline)
for result in results:
print(result)