Exemplo n.º 1
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())
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
class City(Document):
    __collection__ = "AggregationCity"

    city = StringField()
    state = StringField()
    pop = IntField()
Exemplo n.º 4
0
 class TestEmbedded(Document):
     __collection__ = "TestEmbedded"
     num = IntField()
Exemplo n.º 5
0
 class SizeDocument(Document):
     items = ListField(IntField())
     item_size = IntField(default=0,
                          on_save=lambda doc, creating: len(doc.items))
Exemplo n.º 6
0
 class Child(Document):
     __collection__ = "MultipleOperatorsTest"
     num = IntField()
Exemplo n.º 7
0
 class Child(Document):
     __collection__ = "NotOperatorTest"
     num = IntField()
Exemplo n.º 8
0
 class Test2(Document):
     __collection__ = "EmbeddedExistsTest"
     test = IntField()
Exemplo n.º 9
0
 class Child(Document):
     __collection__ = "EmbeddedIsNullTest"
     num = IntField()
Exemplo n.º 10
0
 class Test(Document):
     __collection__ = "LesserThanOrEqual"
     test = IntField()
Exemplo n.º 11
0
 class Test(Document):
     __collection__ = "GreaterThan"
     test = IntField()
Exemplo n.º 12
0
 class ReferenceFieldClass(Document):
     __collection__ = "TestFindAllReferenceField"
     ref1 = ReferenceField(User)
     num = IntField(default=10)
Exemplo n.º 13
0
 class ElemMatchDocument(Document):
     items = ListField(IntField())
Exemplo n.º 14
0
class User(Document):
    name = EmbeddedDocumentField(embedded_document_type=Name)
    email = StringField(db_field="email_address")
    numbers = ListField(base_field=IntField())