Reference field¶
Work with references.
class RDoc(Document):
i = fields.IntegerField
class Doc(Document):
rdoc = fields.ReferenceField(RDoc)
rdoc = RDoc()
rdoc.i = 13
db.insert(rdoc)
doc = Doc()
doc.rdoc = rdoc
db.insert(doc)
doc = db.get_queryset(Doc).with_id(doc.id) # reload doc
assert doc.rdoc.id == rdoc.id
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.