class DocA(Document): test_doc = DocumentField(TestDoc, required=False) test_doc2 = DocumentField(TestDoc2, required=False) def __eq__(self, other): if self.__class__ != other.__class__: return False return self.test_doc.int1 == other.test_doc.int1 def __repr__(self): return 'DocA()'
class User(Document): name_index = Index().ascending('name').unique() name = StringField() email = StringField() address = DocumentField(Address) def __str__(self): return '%s (%s)' % (self.name, self.email)
class Event(Document): name = StringField() children = ListField(DocumentField('Event')) begin = DateTimeField() end = DateTimeField() def __init__(self, name, parent=None): Document.__init__(self, name=name) self.children = [] if parent != None: parent.children.append(self) def __enter__(self): self.begin = datetime.utcnow() return self def __exit__(self, exc_type, exc_val, exc_tb): self.end = datetime.utcnow()
class T2(Document): t = DocumentField(T)
class DocB(Document): a = DocumentField(DocA) b = IntField()
class ParentDoc(Document): t = TupleField(DocumentField('D')) e = EnumField(DocumentField('D'), D(a=1)) d = DictField(DocumentField('D'))
class D(Document): config_namespace = None e = DocumentField('E')
class D(Document): e = DocumentField('E')
class E(Document): d = ListField(ListField(DocumentField('ma.D')))
class E(Document): d = DocumentField('ma.D')
class D(Document): d = DocumentField('D', required=False) a = IntField()
class SuperDoc(Document): int1 = IntField() sub = DocumentField(TestDoc)
class Book(Document): isbn = StringField() pages = ListField(DocumentField(Page))
class Book(Document): isbn = StringField() pages = ListField(DocumentField(Page)) isbn_index = Index().ascending('isbn')
class NestedParent(Document): l = ListField(DocumentField(NestedChild))
class T4(Document): t = DocumentField(T3)