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)
Beispiel #2
0
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())
Beispiel #3
0
 class SizeDocument(Document):
     items = ListField(IntField())
     item_size = IntField(default=0,
                          on_save=lambda doc, creating: len(doc.items))
Beispiel #4
0
 class TestEmbedded(Document):
     __collection__ = "TestEmbedded"
     num = IntField()
Beispiel #5
0
 class Child(Document):
     __collection__ = "NotOperatorTest"
     num = IntField()
Beispiel #6
0
 class Child(Document):
     __collection__ = "MultipleOperatorsTest"
     num = IntField()
Beispiel #7
0
 class Child(Document):
     __collection__ = "EmbeddedIsNullTest"
     num = IntField()
Beispiel #8
0
 class Test2(Document):
     __collection__ = "EmbeddedExistsTest"
     test = IntField()
Beispiel #9
0
 class Test(Document):
     __collection__ = "LesserThanOrEqual"
     test = IntField()
Beispiel #10
0
 class Test(Document):
     __collection__ = "GreaterThan"
     test = IntField()
Beispiel #11
0
 class ReferenceFieldClass(Document):
     __collection__ = "TestFindAllReferenceField"
     ref1 = ReferenceField(User)
     num = IntField(default=10)
Beispiel #12
0
 class ElemMatchDocument(Document):
     items = ListField(IntField())
Beispiel #13
0
class City(Document):
    __collection__ = "AggregationCity"

    city = StringField()
    state = StringField()
    pop = IntField()
class User(Document):
    name = EmbeddedDocumentField(embedded_document_type=Name)
    email = StringField(db_field='email_address')
    numbers = ListField(base_field=IntField())