from app import db
from flask_login import UserMixin


class User(db.Model, UserMixin):
    __tablename__ = 'users'

    uid         = db.Column(db.Integer, primary_key=True)
    username    = db.Column(db.String, nullable=False)
    password    = db.Column(db.String, nullable=False)
    role        = db.Column(db.String, nullable=True)
    description = db.Column(db.String, nullable=True)

    def __repr__(self):
        return f'<User:{self.username}, {self.role}>'

    def get_id(self):
        return self.uid
