GithubHelp home page GithubHelp logo

mdevpro78 / pymongo-wrapper Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 45 KB

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

Python 100.00%
django mongodb pymongo python

pymongo-wrapper's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.