Skip to main content

Minimal Python ODM for MongoDB

Project description

nanomongo is a minimal MongoDB Object-Document Mapper for Python. It does not attempt to be a feature-complete ODM but if you like using pymongo api with python dictionaries and often find yourself writing validators and pymongo.Collection wrappers, nanomongo might suit your needs.

nanomongo has full test coverage.

Quick Links: Source (github) - Documentation (rtd) - Packages (PyPi)

Version 0.4: Utility methods dbref_field_getters, BaseDocument.get_dbref and Bugfix Python23 text type compatibility

Version 0.3: nanomongo is now python2 compatible (with syntactic difference when defining your Document, refer to Documentation)

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

# 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

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

Uploaded Source

Built Distribution

nanomongo-0.4-py2.py3-none-any.whl (16.0 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

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

File hashes

Hashes for nanomongo-0.4.tar.gz
Algorithm Hash digest
SHA256 1771a100d4a2dd3c606531b6a392584f9615e58f290a5c039bfb660b64cfdb12
MD5 542dd36602298083b20765e08a46258a
BLAKE2b-256 10badc2c005baaa940f36fcc580e35db22847a9b5166896d0bf431a909f3a3ef

See more details on using hashes here.

File details

Details for the file nanomongo-0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for nanomongo-0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1d0a2c4a12b206222c75b171bfbe5cea3416e3c0e0ee27af2a8f4ddd7c44a26a
MD5 223efc813a871348b2367149d045e720
BLAKE2b-256 9b3bf3c623b97ce2ab4b50c12086b7dc0c430c772c12e84e515694dfadad2647

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