Skip to main content

A library extend mongoengine.

Project description

https://travis-ci.org/MacHu-GWU/mongoengine_mate-project.svg?branch=master https://codecov.io/gh/MacHu-GWU/mongoengine_mate-project/branch/master/graph/badge.svg https://img.shields.io/pypi/v/mongoengine_mate.svg https://img.shields.io/pypi/l/mongoengine_mate.svg https://img.shields.io/pypi/pyversions/mongoengine_mate.svg https://img.shields.io/badge/Star_Me_on_GitHub!--None.svg?style=social

Welcome to mongoengine_mate Documentation

mongoengine_mate is a library extend power of mongoengine

Usage

import mongoengine
from mongoengine_mate import ExtendedDocument

class User(ExtendedDocument):
    id = mongoengine.IntField()
    name = mongoengine.StringField()

First, you got better __repr__() like:

>>> User(id=1, name="Alice")
User(id=1, name="Alice")

Then, you got more built-in method to do:

# smart_insert, automatically handle NotUniqueError
User.smart_insert([
    User(id=1, name="Alice"),
    User(id=2, name="Bob"),
])

# access its collection or database
col_user = User.col()
col_db = User.db()

# access its field name in order
>>> User.fields_ordered()
["id", "name"]

# provide dictionary-like api
>>> user = User(id=1, name="Alice")
>>> user.keys()
["id", "name"]
>>> user.values()
[1, "Alice"]
>>> user.items()
[("id", "name"), (1, "Alice")]
>>> user.to_dict()
{"id": 1, "name": "Alice"}
>>> user.to_OrderedDict()
OrderedDict([("id", "name"), (1, "Alice")])

More examples can be found at https://github.com/MacHu-GWU/mongoengine_mate-project/blob/master/mongoengine_mate/document.py

Install

mongoengine_mate is released on PyPI, so all you need is:

$ pip install mongoengine_mate

To upgrade to latest version:

$ pip install --upgrade mongoengine_mate

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

mongoengine_mate-0.0.3.tar.gz (17.6 kB view hashes)

Uploaded Source

Built Distribution

mongoengine_mate-0.0.3-py2-none-any.whl (29.5 kB view hashes)

Uploaded Python 2

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