class User(BaseDocument):
    """
    This document stores the user information and data
    as the number of victories and defeats
    """
    username = fields.StrField(
        required=True,
        unique=True,
        validate=[validate.Length(min=6, max=20)],
    )

    email = fields.StrField(
        required=True,
        unique=True,
        validate=validate.Email(),
    )

    victories = fields.IntField(
        default=0,
    )

    created_at = fields.DateTimeField(
        default=datetime.datetime.now(),
    )

    class Meta:
        """
        ODM Metadata
        """
        collection = db.users
示例#2
0
 class WithMailUser(self.User):
     email = fields.StrField(
         validate=[validate.Email(),
                   validate.Length(max=100)])
     number_of_legs = fields.IntField(
         validate=[validate.OneOf([0, 1, 2])])