Embedded documents fields¶
Work with embedded documents.
class EDoc(EmbeddedDocument):
i = fields.IntegerField()
class Doc(Document):
__collection__ = 'docs'
edoc = EmbeddedDocumentField(EDoc)
doc = Doc()
doc.edoc = EDoc()
doc.edoc.i = 13
db.insert(doc)
-
class
yadm.fields.embedded.
EmbeddedDocumentField
(embedded_document_class, *, auto_create=True, **kwargs)¶ Field for embedded objects.
Parameters: - embedded_document_class (EmbeddedDocument) – class for embedded document
- auto_create (bool) – automatic creation embedded document from access
-
copy
()¶ Return copy of field.
-
get_if_attribute_not_set
(document)¶ Call if key not exist in document.
If auto_create is True, create and return new embedded document. Else AttributeError is raised.