Git Product home page Git Product logo

mongous's Introduction

Mongous

Build Status Coverage Status PyPI version

A (very) thin wrapper on top of PyMongo CRUD functions in order to use some different query syntax. Another possible use is that the SimpleCRUDHandler class could be used as a base class for database models. Tested to work on Python 2.7, 3.3, 3.4, 3.5, pypy, and pypy3.

Example

BEFORE (with PyMongo)

from pymongo import MongoClient as Client

posts = Client().blog.posts
results = posts.find_one({"title": "Moby Dick"})

AFTER (with Mongous)

from mongous import SimpleMongoCRUDHandler as Handler

posts = Handler("blog", "posts")
results = posts.read(title="Moby Dick")

Installation

$ pip install mongous

Alternatively, you can download the source code and install to your library:

$ python setup.py install

In some cases you might need to do this:

$ sudo python setup.py install

API

class SimpleMongoCRUDHandler

__init__(self, database_name, collection_name, connection=None)

Constructor, sets database to database_name, collection to collection_name, and optionally uses the connection string connection if supplied.

create(self, **kwargs)

returns the return value of PyMongo.MongoClient.insert_one with kwargs passed as a dict

create_many(self, documents)

returns the return value of PyMongo.MongoClient.insert_many with documents passed

read(self, **kwargs)

returns the return value of PyMongo.MongoClient.find_one with kwargs passed as a dict

read_many(self, **kwargs)

returns the return value of PyMongo.MongoClient.read_many with kwargs passed as a dict

update(self, doc, **kwargs)

returns the return value of PyMongo.MongoClient.update_many with doc and kwargs passed as dicts (the second argument being a blend of both doc and kwargs minus _id so you don't have to add everything manually to an update query)

delete(self, **kwargs)

returns the return value of PyMongo.MongoClient.delete_many with kwargs passed as a dict

mongous's People

Contributors

nonproftechie avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

digideskio

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.