Metadata-Version: 1.1
Name: Mongo-Thingy
Version: 0.1.2
Summary: The most Pythonic and friendly-yet-powerful way to use MongoDB
Home-page: https://github.com/numberly/mongo-thingy
Author: Guillaume Gelin
Author-email: ramnes@1000mercis.com
License: MIT
Description: .. _Thingy: https://github.com/numberly/thingy
        
        ============
        Mongo-Thingy
        ============
        
        Mongo-Thingy is the most Pythonic and friendly-yet-powerful way to use MongoDB.
        
        Its main goal is give you full advantage of MongoDB schema-less design by NOT
        asking you to define schemas in your code.
        
        It also has cool "side-features" such as views (inherited from Thingy_),
        database/collection "discovery", and more!
        
        
        Install
        =======
        
        .. code-block:: sh
        
           $ pip install mongo-thingy
        
        
        Examples
        ========
        
        First steps
        -----------
        
        Connect, insert and find thingies
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
        .. code-block:: python
        
           >>> from mongo_thingy import connect, Thingy
           >>> connect("mongodb://localhost/test")
        
           >>> class User(Thingy):
           ...     pass
        
           >>> user = User({"name": "Mr. Foo", "age": 42}).save()
           >>> User.count()
           1
           >>> User.find_one({"age": 42})
           User({'_id': ObjectId(...), 'name': 'Mr. Foo', 'age': 42})
        
        
        Update thingies
        ~~~~~~~~~~~~~~~
        
        .. code-block:: python
        
           >>> user.age
           42
           >>> user.age = 1337
           >>> user.save()
           User({'_id': ObjectId(...), 'name': 'Mr. Foo', 'age': 1337})
        
        
        Thingy's views power
        --------------------
        
        Complete information with properties
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
        .. code-block:: python
        
           >>> class User(Thingy):
           ...     @property
           ...     def username(self):
           ...         return "".join(char for char in self.name if char.isalpha())
        
           >>> User.add_view(name="everything", defaults=True, include="username")
           >>> user = User.find_one()
           >>> user.view("everything")
           {'_id': ObjectId(...), 'name': 'Mr. Foo', 'age': 1337, 'username': 'MrFoo'}
        
        
        Hide sensitive stuff
        ~~~~~~~~~~~~~~~~~~~~
        
        .. code-block:: python
        
           >>> User.add_view(name="public", defaults=True, exclude="password")
           >>> user.password = "t0ps3cr3t"
           >>> user.view()
           {'_id': ObjectId(...), 'name': 'Mr. Foo', 'age': 1337, 'password': 't0ps3cr3t'}
           >>> user.view("public")
           {'_id': ObjectId(...), 'name': 'Mr. Foo', 'age': 1337}
        
        
        Only use certain fields/properties
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
        .. code-block:: python
        
           >>> User.add_view(name="credentials", include=["username", "password"])
           >>> user.view("credentials")
           {'username': 'mrbar', 'password': 't0ps3cr3t'}
        
        
        Database/collection "discovery"
        -------------------------------
        
        .. code-block:: python
        
           >>> class AuthenticationGroup(Thingy):
           ...     pass
        
           >>> connect("mongodb://localhost/")
           >>> AuthenticationGroup.database.name
           "authentication"
           >>> AuthenticationGroup.collection.name
           "group"
        
        
        Tests
        =====
        
        To run Mongo-Thingy tests:
        
        * make sure you have a MongoDB database running on ``localhost:27017``;
        * install developers requirements with ``pip install -r requirements.txt``;
        * run ``pytest``.
        
        
        License
        =======
        
        MIT
        
Platform: any
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
