class ChatRoom(db.Model): __tablename__ = 'chatroom' id = db.Column(db.Integer, primary_key=True) roomname = db.Column(db.String(50), nullable=False, unique=True) def __init__(self, roomname): self.roomname = roomname
class ChatLog(db.Model): log_id = db.Column(db.Integer, primary_key=True) message = db.Column(db.String(100), nullable=False) userfrom = db.Column(db.String(20), db.ForeignKey('users.username'), nullable=False) created_date = db.Column(db.DateTime(timezone=True)) room_name = db.Column(db.String(20), db.ForeignKey('chatroom.room_name')) def __init__(self, message, userfrom, created_date, room_name="None"): self.message = message self.userfrom = userfrom self.created_date = created_date self.room_name = room_name def update(self: ChatLog, interface: ChatLogInterface) -> ChatLog: """Update to an existing room with a ChatLogInterface Parameters ---------- interface: ChatLogInterface The log interface containing the changes to be implemented. Returns: ChatLog: The log with the updated changes. """ for key, val in interface.items(): setattr(self, key, val) return self
class Orders(db.Model): id = db.Column(db.Integer, primary_key=True) order_type = db.Column(db.String(30), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False) order_amount = db.Column(db.Float, nullable=False) booster_assigned = db.Column(db.String(20), db.ForeignKey('users.username')) def __init__(order_type, user_id, order_amount, booster_assigned="None"): self.message = message self.userfrom = userfrom self.created_date = created_date self.booster_assigned = booster_assigned
class ChatLog(db.Model): id = db.Column(db.Integer, primary_key=True) message = db.Column(db.String(100), nullable=False) userfrom = db.Column(db.String(20), db.ForeignKey('users.username'), nullable=False) created_date = db.Column(db.DateTime(timezone=True)) room = db.Column(db.String(20), db.ForeignKey('chatroom.roomname')) def __init__(self, message, userfrom, created_date, room="None"): self.message = message self.userfrom = userfrom self.created_date = created_date self.room = room
class User(UserMixin, db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True) email = db.Column(db.String(50), unique=True) password = db.Column(db.String(80)) role = db.Column(db.String(80)) def __init__(self, username, email, password, role="None"): self.username = username self.email = email self.password = password self.role = role
class ChatRoom(db.Model): __tablename__ = 'chatroom' room_id = db.Column(db.Integer, primary_key=True) room_name = db.Column(db.String(50), nullable=False, unique=True) def __init__(self, room_name): self.room_name = room_name def update(self: ChatRoom, interface: ChatRoomInterface) -> ChatRoom: """Update to an existing room with a ChatRoomInterface Parameters ---------- interface: ChatRoomInterface The room interface containing the changes to be implemented. Returns: ChatRoom: The room with the updated changes. """ for key, val in interface.items(): setattr(self, key, val) return self