Reference field

Work with references.

class RDoc(Document):
    i = fields.IntegerField

class Doc(Document):
    rdoc = fields.ReferenceField(RDoc)

rdoc = RDoc()
rdoc.i = 13

doc = Doc()
doc.rdoc = rdoc

doc = db.get_queryset(Doc).find_one(  # reload doc
assert ==
assert doc.rdoc.i == 13
exception yadm.fields.reference.BrokenReference

Raise if referrenced document is not found.

exception yadm.fields.reference.NotBindingToDatabase

Raise if set ObjectId insted referenced document to new document, who not binded to database.

class yadm.fields.reference.ReferenceField(reference_document_class, **kwargs)

Field for work with references.

Parameters:reference_document_class – class for refered documents
get_fake(document, faker, depth)

Try create referenced document.