class BaseModel(db.Model): """ a base model for other database tables to inherit """ __abstract__ = True id = db.Column(db.Integer, primary_key=True) date_created = db.Column(db.DateTime, default=db.func.current_timestamp()) date_modified = db.Column(db.DateTime, default=db.func.current_timestamp(), onupdate=db.func.current_timestamp())
class Base(db.Model): __abstract__ = True id = db.Column(db.Integer, primary_key=True) created_date = db.Column(db.DateTime, default=db.func.current_timestamp()) modefied_date = db.Column(db.DateTime, default=db.func.current_timestamp(), onupdate=db.func.current_timestamp())
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(50), nullable=False) lastlogin = db.Column(db.DateTime, nullable=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.lastlogin}')"
class ClockInOutHistory(Base): ''' define check in history ''' __tablename__ = 'clock_in_out' clock_in_or_out = db.Column(db.String(10)) clock_datetime = db.Column(db.DateTime, default=db.func.current_timestamp()) operator_id = db.Column(db.Integer, ForeignKey('users.id')) user_id = db.Column(db.Integer, ForeignKey('users.id'))
class User(Base): ''' define user model ''' __tablename__ = 'users' public_id = db.Column(db.String(128), unique=True) name = db.Column(db.String(60)) email = db.Column(db.String(256)) hashed_pwd = db.Column(db.String(256)) birth = db.Column(db.DateTime) salt = db.Column(db.String(50)) phone = db.Column(db.String(60)) dpmt = db.Column(db.String(60)) status = db.Column(db.String(60)) img_url = db.Column(db.String(300))
class APIAuth(BaseModel): """ Model for APIKEYs. """ id = db.Column(db.Integer, primary_key=True) key = db.Column(db.String(120), unique=True) ip = db.Column(db.String(120), unique=False) description = db.Column(db.String(255), unique=False) def __init__(self, key, ip, description): self.key = key self.ip = ip self.description = description def __repr__(self): return '<Key %r>' % self.ip
class User(db.Model): id = db.Column(db.Integer, primary_key=True) public_id = db.Column(db.String(50), unique=True) name = db.Column(db.String(50)) password = db.Column(db.String(80)) admin = db.Column(db.Boolean)
class Todo(db.Model): id = db.Column(db.Integer, primary_key=True) text = db.Column(db.String(50)) complete = db.Column(db.Boolean) user_id = db.Column(db.Integer)