class Post(Document):
    __collection__ = "posts"

    title = StringField(required=True)
    text = StringField(required=True, db_field="content")
    category = ReferenceField(reference_document_type=Category)
    comments = ListField(EmbeddedDocumentField(embedded_document_type=Comment))
Example #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())
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)
Example #4
0
 class SizeDocument(Document):
     items = ListField(IntField())
     item_size = IntField(default=0,
                          on_save=lambda doc, creating: len(doc.items))
class Post(Document):
    title = StringField(required=True)
    body = StringField(required=True)

    comments = ListField(EmbeddedDocumentField(Comment))
Example #6
0
 class Base(Document):
     __collection__ = "base"
     __lazy__ = False
     list_val = ListField(ReferenceField(reference_document_type=Ref))
Example #7
0
 class RawQueryDocument(Document):
     items = ListField(EmbeddedDocumentField(RawQueryEmbeddedDocument))
Example #8
0
 class ElemMatchEmbeddedParentDocument(Document):
     items = ListField(EmbeddedDocumentField(ElemMatchEmbeddedDocument))
Example #9
0
 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())