Skip to main content

Access embedded documents with CRUD by id.

Project description

[![PyPI version](https://badge.fury.io/py/mongoengine-embedded.svg)](https://badge.fury.io/py/mongoengine-embedded)
# mongoengine-embedded

This package provides basic CRUD methods on EmbeddedDocumentListField through \_id.

## Usage

```python
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:

```bash
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

mongoengine-embedded-1.0.0.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file mongoengine-embedded-1.0.0.tar.gz.

File metadata

File hashes

Hashes for mongoengine-embedded-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1067eca5b0b4b928566844a284891b32b0658f8fccfa255efa1074c31f272f90
MD5 f262f1c0dd1d5ac2d2f7a83d4c04c8fe
BLAKE2b-256 9cdd3b4ec52222d1e46b5a037ae9ff54709bd4153f6580b1ec34ec32bc91761d

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