Skip to content

schemaless pymongo wrapper to make the advance mongodb query based on the pymongo package

Notifications You must be signed in to change notification settings

Mdevpro78/pymongo-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project logo

Pymongo Wrapper

Status GitHub Pull Requests License


Few lines describing your project.
This Python Package called PyMongo Wrapper wrapp the Pymongo python package for projects which are schemaless

📝 Table of Contents

🧐 About

PyMongo Wrapper provides a simple wrapper around pymongo which is providing CRUD functionality on the MongoDB when we don't have Schema (Schemaless)

🏁 Getting Started

Prerequisites

What things you need to install the software and how to install them.

git clone https://github.com/Mdevpro78/pymongo-wrapper.git

Installing

A step by step series to install the package

cd pymongo-wrapper
python setup.py install

or just

pip install .

🎈 Usage

for Python Project

to build Db Repository

from repository import DBRepository

collection_name = 'my_collection'
database_name = 'my_database'
uri = 'mongodb://localhost:27017/'

db_repo = DBRepository(collection_name, database_name, uri)

To build Pipeline

# 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

# Example usage of query_repo()
query_repo = db_repo.query_repo()
results = query_repo.aggregate(pipeline)
for result in results:
    print(result)

⛏️ Built Using

✍️ Authors

About

schemaless pymongo wrapper to make the advance mongodb query based on the pymongo package

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages