Skip to main content

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).

https://travis-ci.org/eguven/nanomongo.png

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!

Author:

Eren Güven (GitHub, Twitter)

License:

Apache Software License

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.2.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

nanomongo-0.2-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file nanomongo-0.2.tar.gz.

File metadata

  • Download URL: nanomongo-0.2.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nanomongo-0.2.tar.gz
Algorithm Hash digest
SHA256 84bc7818d4989b1c72ca61da3426c1d456d114a99bb1cfa6a9b6967d9f78256b
MD5 1e5c01997852872a0b2c4b7776fe397a
BLAKE2b-256 fcecc8247f07d66780596c76b7f5ff12ac56708b771c796ee7bcd4a0a8840095

See more details on using hashes here.

File details

Details for the file nanomongo-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for nanomongo-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d82b49dce03cba0e6946c0d93b73ed358568a97c6f47143ad36633cbeafbf145
MD5 30742d6d81debe22099e5976d5e2e7a3
BLAKE2b-256 76cde209291ca087e1e427d9a032b91fa29e1c1d01e92b3f6e1d57bb9316a8f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page