class User(Document): __collection__ = "AggregationUser" email = StringField(required=True) first_name = StringField(max_length=50, default=lambda: "Bernardo") last_name = StringField(max_length=50, default="Heynemann") is_admin = BooleanField(default=True) updated_at = DateTimeField(required=True, auto_now_on_insert=True, auto_now_on_update=True) number_of_documents = IntField() list_items = ListField(IntField())
class User(Document): __collection__ = "users" index = IntField(required=True) email = StringField(required=True) first_name = StringField(db_field="whatever", max_length=50, default=lambda: "Bernardo") last_name = StringField(max_length=50, default="Heynemann") is_admin = BooleanField(default=True) website = URLField(default="http://google.com/") updated_at = DateTimeField(required=True, auto_now_on_insert=True, auto_now_on_update=True) embedded = EmbeddedDocumentField(EmbeddedDocument, db_field="embedded_document") nullable = EmbeddedDocumentField(EmbeddedDocument, db_field="nullable_embedded_document") numbers = ListField(IntField()) posts = ListField(ReferenceField(reference_document_type=Post)) def __repr__(self): return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
class City(Document): __collection__ = "AggregationCity" city = StringField() state = StringField() pop = IntField()
class TestEmbedded(Document): __collection__ = "TestEmbedded" num = IntField()
class SizeDocument(Document): items = ListField(IntField()) item_size = IntField(default=0, on_save=lambda doc, creating: len(doc.items))
class Child(Document): __collection__ = "MultipleOperatorsTest" num = IntField()
class Child(Document): __collection__ = "NotOperatorTest" num = IntField()
class Test2(Document): __collection__ = "EmbeddedExistsTest" test = IntField()
class Child(Document): __collection__ = "EmbeddedIsNullTest" num = IntField()
class Test(Document): __collection__ = "LesserThanOrEqual" test = IntField()
class Test(Document): __collection__ = "GreaterThan" test = IntField()
class ReferenceFieldClass(Document): __collection__ = "TestFindAllReferenceField" ref1 = ReferenceField(User) num = IntField(default=10)
class ElemMatchDocument(Document): items = ListField(IntField())
class User(Document): name = EmbeddedDocumentField(embedded_document_type=Name) email = StringField(db_field="email_address") numbers = ListField(base_field=IntField())