Access embedded documents with CRUD by id.
Project description
mongoengine-embedded
This package provides basic CRUD methods on EmbeddedDocumentListField through _id.
Usage
import mongoengine
from mongoengine_embedded import EmbeddedResource, ResourceContainer
# embedded resource
class Masterpiece(mongoengine.EmbeddedDocument, EmbeddedResource):
title = mongoengine.StringField()
# document contains embedded resource
@ResourceContainer
class Monkey(mongoengine.Document):
masterpieces = mongoengine.EmbeddedDocumentListField(
Masterpiece, element_name='masterpiece')
the_monkey = Monkey()
the_monkey.save()
# Create
one_masterpiece = the_monkey.create_masterpiece(title='Complete Works of William Shakespeare')
another_masterpiece = the_monkey.create_masterpiece(title='Siku Quanshu')
another_id = another_masterpiece.id
# Read
another = the_monkey.get_masterpiece_by_id(another_id)
# Update
the_monkey.modify_masterpiece_by_id(another_id, set__name='Jing Shi Zi Ji')
# Destroy
the_monkey.destroy_masterpiece_by_id(another_id)
Installation
This Package can be installed through pip:
pip install mongoengine-embedded
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
Close
Hashes for mongoengine-embedded-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4215e88ac2c1dd3d18bf297d76ac2158f67eaa0af98b673127daccccd3e375e8 |
|
MD5 | 5c714e2495d312fceb4cb48745d5a5de |
|
BLAKE2b-256 | 8f13c3f7df972224ed34d59ef11fe8384e5221dd67013b25e431f1f59aaf13aa |