A library extend mongoengine.
Project description
Welcome to mongoengine_mate Documentation
mongoengine_mate is a library extend power of mongoengine
Quick Links
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 details)
Built Distribution
File details
Details for the file mongoengine_mate-0.0.3.tar.gz
.
File metadata
- Download URL: mongoengine_mate-0.0.3.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db6e4d7ab409a1a2dee0784fcfaf900e8e80fd30649b176cc3a64661152238bb |
|
MD5 | 017add88897c9e0b9860196686d0922b |
|
BLAKE2b-256 | 0fedac13b7d3061f47fb901683b6d6afc7a74d0274567022025e50d48d224044 |
File details
Details for the file mongoengine_mate-0.0.3-py2-none-any.whl
.
File metadata
- Download URL: mongoengine_mate-0.0.3-py2-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77ab03d26dcf94a2a9bcbaad99f8225970f1615a34a51fec187ce4e765269e2e |
|
MD5 | c5433a7313698de33d93b6cb004fa0c6 |
|
BLAKE2b-256 | 23edabef8aabc3553d45dcbddb90a6446d17f1b6396202665727243c313c8502 |