Git Product home page Git Product logo

minimongo's Introduction

minimongo

Info

Minimal database Model management for MongoDB.

Author

Steve Lacy ([email protected])

About

minimongo is a lightweight, schemaless, Pythonic Object-Oriented interface to MongoDB.

It provides a very thin, dynamicly typed (schema-less) object management layer for any data stored in any MongoDB collection. minimongo directly calls the existing pymongo query syntax.

minimongo can easily layer on top of existing MongoDB collections, and will work properly with almost any existing schema, even from third party applications.

Installation

If you have setuptools you can use easy_install -U minimongo. Otherwise, you can download the source from GitHub and run python setup.py install.

Dependencies

Example

Here's a very brief example of creating an object, querying for it, modifying a field, and then saving it back again:

from minimongo import Model, Index

class Foo(Model):
    class Meta:
        # Here, we specify the database and collection names.
        # A connection to your DB is automatically created.
        database = "minimongo"
        collection = "rocks"

        # Now, we programatically declare what indices we want.
        # The arguments to the Index constructor are identical to
        # the args to pymongo"s ensure_index function.
        indices = (
            Index("a"),
        )


if __name__ == "__main__":
    # Create & save an object, and return a local in-memory copy of it:
    foo = Foo({"x": 1, "y": 2}).save()

    # Find that object again, loading it into memory:
    foo = Foo.collection.find_one({"x": 1})

    # Change a field value, and save it back to the DB.
    foo.other = "some data"
    foo.save()

Feedback welcome!

Please email [email protected] with comments, suggestions, or comment via http://github.com/slacy/minimongo

minimongo's People

Contributors

knsd avatar slacy avatar superbobry avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.