Beispiel #1
0
class Reporter(mongoengine.Document):
    meta = {"collection": "test_reporter"}
    id = mongoengine.StringField(primary_key=True)
    first_name = mongoengine.StringField(required=True)
    last_name = mongoengine.StringField(required=True)
    email = mongoengine.EmailField()
    awards = mongoengine.ListField(mongoengine.StringField())
    articles = mongoengine.ListField(mongoengine.ReferenceField(Article))
    embedded_articles = mongoengine.ListField(
        mongoengine.EmbeddedDocumentField(EmbeddedArticle))
    embedded_list_articles = mongoengine.EmbeddedDocumentListField(
        EmbeddedArticle)
    generic_reference = mongoengine.GenericReferenceField(
        choices=[Article, Editor], required=True)
    generic_embedded_document = mongoengine.GenericEmbeddedDocumentField(
        choices=[EmbeddedArticle, EmbeddedFoo])
    generic_references = mongoengine.ListField(
        mongoengine.GenericReferenceField(choices=[Article, Editor]))
Beispiel #2
0
 class Doc(me.Document):
     id = me.StringField(primary_key=True, default='main')
     embedded = me.GenericEmbeddedDocumentField()