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))
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 User(Document):
    email = StringField(required=True)
    first_name = StringField(max_length=50)
    last_name = StringField(max_length=50)
    is_admin = BooleanField(default=True)

    def __repr__(self):
        return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
Exemplo n.º 4
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.º 5
0
class User(Document):
    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)
    website = URLField(default="http://google.com/")
    updated_at = DateTimeField(required=True,
                               auto_now_on_insert=True,
                               auto_now_on_update=True)
    facebook_id = StringField(unique=True, sparse=True)

    def __repr__(self):
        return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
Exemplo n.º 6
0
 def test_can_create_query_operator(self):
     query = QueryOperator()
     expect(query).not_to_be_null()
     expect(query.get_value(StringField(),
                            "some value")).to_equal("some value")
Exemplo n.º 7
0
class Post(Document):
    title = StringField(required=True)
    body = StringField(required=True)

    comments = ListField(EmbeddedDocumentField(Comment))
Exemplo n.º 8
0
class Comment(Document):
    __collection__ = "CommentBulk"
    text = StringField(required=True)
Exemplo n.º 9
0
class Comment(Document):
    text = StringField(required=True)
    user = ReferenceField(User, required=True)
Exemplo n.º 10
0
class CommentNotLazy(Document):
    __lazy__ = False

    text = StringField(required=True)
    user = ReferenceField(User, required=True)
Exemplo n.º 11
0
class Category(Document):
    __collection__ = 'categories'

    name = StringField(required=True)
    descr = StringField(required=True)
Exemplo n.º 12
0
 class Model(Document):
     last_name = StringField(db_field="db_last", default="Heynemann")
     first_name = StringField(db_field="db_first",
                              default=lambda: "Bernardo")
Exemplo n.º 13
0
class User(Document):
    name = StringField()
Exemplo n.º 14
0
class User(Document):
    name = EmbeddedDocumentField(embedded_document_type=Name)
    email = StringField(db_field='email_address')
    numbers = ListField(base_field=IntField())
Exemplo n.º 15
0
 class Ref(Document):
     __collection__ = 'ref'
     val = StringField()
Exemplo n.º 16
0
 class DuplicateField(User):
     email = StringField(required=True)
Exemplo n.º 17
0
 class RawQueryEmbeddedDocument(Document):
     name = StringField()
Exemplo n.º 18
0
 class ElemMatchEmbeddedDocument(Document):
     name = StringField()
Exemplo n.º 19
0
 class Version2Document(Document):
     __collection__ = "TestDynamicFieldDocumentQuery1"
     old_element = StringField(default="old_string_field")
     new_element = StringField(default="new_string_field")
Exemplo n.º 20
0
class EmbeddedDocument2(Document):
    test = StringField(db_field="else", required=False)
Exemplo n.º 21
0
class City(Document):
    __collection__ = "AggregationCity"

    city = StringField()
    state = StringField()
    pop = IntField()
Exemplo n.º 22
0
class EmbeddedDocument(Document):
    test = StringField(db_field="other", required=True)
    embedded2 = EmbeddedDocumentField(EmbeddedDocument2)
Exemplo n.º 23
0
class Employee(User):
    emp_number = StringField()
Exemplo n.º 24
0
class Comment(Document):
    title = StringField(required=True)
    text = StringField(required=True)
Exemplo n.º 25
0
 class UniqueSparseFieldDocument(Document):
     unique_id = StringField(unique=True, sparse=True)
Exemplo n.º 26
0
 class UniqueFieldDocument(Document):
     name = StringField(unique=True)
Exemplo n.º 27
0
class Name(Document):
    last = StringField(db_field='last_name')
    first = StringField()