class Feed(Document): type = fields.StringField(required=True) uri = fields.StringField() name = fields.StringField(required=True) last_ts = fields.NumberField(required=True, default=0) class Meta: collection_name = "feed"
class Product(Document): category = fields.ReferenceField(Category) name = fields.StringField(required=True, unique=True) description = fields.StringField(required=True, unique=True) price = fields.NumberField(required=True) image_url = fields.UrlField() available_from = fields.DateTimeField() available_till = fields.DateTimeField()
class MySchema(Schema): string = fields.StringField() uuid = fields.UUIDField() number = fields.NumberField() integer = fields.IntegerField() decimal = fields.DecimalField() boolean = fields.BooleanField() float = fields.FloatField() url = fields.UrlField() email = fields.EmailField() constant = fields.ConstantField("const")
class Product(Document): # id_prod = fields.IntegerField() id_cat = fields.ReferenceField(Category) name_prod = fields.StringField(required=True, unique=True) description = fields.StringField(required=True, unique=True) price = fields.NumberField(required=True) image_url_prod = fields.UrlField() avail_from = fields.DateTimeField() avail_till = fields.DateTimeField() class Meta: collection = db.product
class MySchema(EmbeddedSchema): string = fields.StringField() uuid = fields.UUIDField() number = fields.NumberField() integer = fields.IntegerField() decimal = fields.DecimalField() boolean = fields.BooleanField() formattedstring = fields.FormattedStringField('Hello {to_format}') float = fields.FloatField() # localdatetime = fields.LocalDateTimeField() url = fields.UrlField() email = fields.EmailField() constant = fields.ConstantField("const")
class Article(Document): ts = fields.NumberField(required=True, default=0) text = fields.StringField() tags = fields.ListField(fields.StringField(), default=[]) source = fields.ReferenceField("Feed") address = fields.StringField(default="") # Location: { # type: "Point", # coordinates: [-73.856077, 40.848447] # } location = fields.DictField(default={}) class Meta: collection_name = "article"