Minimal Python ODM for MongoDB
Project description
=========
nanomongo
=========
If you like using ``pymongo`` native api but often find yourself subclassing
``dict`` to add some extra logic and while you're at it, why not add some
field validations right? And index definitions, and ``pymongo.Collection``
wrappers, and ... (you get the idea).
.. image:: https://travis-ci.org/eguven/nanomongo.png
:target: https://travis-ci.org/eguven/nanomongo
Features
--------
- single format ``Field`` definitions with type checking and a few common
options such as ``required``, ``default``, ``auto_update``
- ``pymongo``-identical index definitions
- optional ``dot_notation``
- assignment and deletion (delta) tracking for ``'$set'`` and ``'$unset'``
and atomic updates; you either insert or update
- ``'$addToSet'`` on ``Document``
- *upcoming* ``'$push'`` ``'$pull'`` funtionality
# rough example
import pymongo
from nanomongo import Field, BaseDocument, Index
client = pymongo.MongoClient()
class MyDoc(BaseDocument, dot_notation=True, client=client, db='dbname'):
foo = Field(str)
bar = Field(int, required=False)
__indexes__ = [
Index('foo'),
Index([('bar', 1), ('foo', -1)], unique=True),
]
doc = MyDoc(foo='L33t')
doc.bar = 42
doc.insert()
Doc.find_one({'foo': 'L33t'})
nanomongo is Python23 compatible and I intend to support both pymongo & motor
transparently under the hood.
Contributions and insight are welcome!
:Author: Eren Güven (GitHub_, Twitter_)
:License: Apache Software License
.. _GitHub: https://github.com/eguven
.. _Twitter: https://twitter.com/cyberfart
nanomongo
=========
If you like using ``pymongo`` native api but often find yourself subclassing
``dict`` to add some extra logic and while you're at it, why not add some
field validations right? And index definitions, and ``pymongo.Collection``
wrappers, and ... (you get the idea).
.. image:: https://travis-ci.org/eguven/nanomongo.png
:target: https://travis-ci.org/eguven/nanomongo
Features
--------
- single format ``Field`` definitions with type checking and a few common
options such as ``required``, ``default``, ``auto_update``
- ``pymongo``-identical index definitions
- optional ``dot_notation``
- assignment and deletion (delta) tracking for ``'$set'`` and ``'$unset'``
and atomic updates; you either insert or update
- ``'$addToSet'`` on ``Document``
- *upcoming* ``'$push'`` ``'$pull'`` funtionality
# rough example
import pymongo
from nanomongo import Field, BaseDocument, Index
client = pymongo.MongoClient()
class MyDoc(BaseDocument, dot_notation=True, client=client, db='dbname'):
foo = Field(str)
bar = Field(int, required=False)
__indexes__ = [
Index('foo'),
Index([('bar', 1), ('foo', -1)], unique=True),
]
doc = MyDoc(foo='L33t')
doc.bar = 42
doc.insert()
Doc.find_one({'foo': 'L33t'})
nanomongo is Python23 compatible and I intend to support both pymongo & motor
transparently under the hood.
Contributions and insight are welcome!
:Author: Eren Güven (GitHub_, Twitter_)
:License: Apache Software License
.. _GitHub: https://github.com/eguven
.. _Twitter: https://twitter.com/cyberfart
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nanomongo-0.3.1.tar.gz
(18.1 kB
view details)
Built Distribution
File details
Details for the file nanomongo-0.3.1.tar.gz
.
File metadata
- Download URL: nanomongo-0.3.1.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf86e8b30702f1677443b57a3e3011c2d4f71de77e90b277a1cf2925509c9972 |
|
MD5 | 4b98f6dd1a8c758c86a4ebda48181ec9 |
|
BLAKE2b-256 | 4ace0cfa5ec01f3f5563f53821bbfa25d7958b25006775573c8f23ca90e6cca7 |
File details
Details for the file nanomongo-0.3.1-py2.py3-none-any.whl
.
File metadata
- Download URL: nanomongo-0.3.1-py2.py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20e7f0c87dadb111393793bfe7af6ae6ddc6c3f7e8d4f494fe4f03ffae76d2a2 |
|
MD5 | 31ceae11ed68c61f1098193c277b73ed |
|
BLAKE2b-256 | b6b002393f88cca842e970fc11a34bc2e4258c003d959f5e9a71825667c72e0f |