Minimal Python ODM for MongoDB
Project description
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).
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!
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
Built Distribution
File details
Details for the file nanomongo-0.3.3.tar.gz
.
File metadata
- Download URL: nanomongo-0.3.3.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 456a8a6172814803fa607147b70c563a785b883dcff29c7224132910a5b7b8a7 |
|
MD5 | ee0622c1f542ef9c7d5c78ff04df9ef3 |
|
BLAKE2b-256 | d0529eed4e59d886c3e474b5a19a509cef4c81d08ecfb63bd788818161afb04f |
File details
Details for the file nanomongo-0.3.3-py2.py3-none-any.whl
.
File metadata
- Download URL: nanomongo-0.3.3-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 | 162e35158c188663d230c43dd71bbd0630c4a4f549cd8eb28d7d6b9c3d4b8de6 |
|
MD5 | f00337547825db3e505eb3a2690de044 |
|
BLAKE2b-256 | 9c86d7d2ff35d45a7949b4698213862d3d81db6be357bdda17da25717ae8c06c |