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
note: nanomongo is in alpha stage and in development, documentation is in progress as well:
# 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 written for Python3 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nanomongo-0.3.tar.gz.
File metadata
- Download URL: nanomongo-0.3.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9712144050a9b63f54b7e0308eb44304fb3c6a988eb7dcd41f6ad26df878fcd
|
|
| MD5 |
ed371e60ef4b9c14172008365fe325ac
|
|
| BLAKE2b-256 |
405240400f55b664fff1f82cff156ed47dfc15cecc0027e4ebb78f9b804e6130
|
File details
Details for the file nanomongo-0.3-py2.py3-none-any.whl.
File metadata
- Download URL: nanomongo-0.3-py2.py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2163bf45be647cab4c6d497d43959b96709975f291ba7f7da696b7bf0f59cf78
|
|
| MD5 |
2134945bea88190f58b1e73298166800
|
|
| BLAKE2b-256 |
ce5e2eb7a2b6682111721bfc63d08cd63ed33ecd92a8c84d5a162beb5d0856b5
|