Commit 48cc2c50 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

chore: delete user backend refac

parent 7fade0bb
...@@ -153,5 +153,14 @@ class ChatTable: ...@@ -153,5 +153,14 @@ class ChatTable:
except: except:
return False return False
def delete_chats_by_user_id(self, user_id: str) -> bool:
try:
query = Chat.delete().where(Chat.user_id == user_id)
query.execute() # Remove the rows, return number of rows removed.
return True
except:
return False
Chats = ChatTable(DB) Chats = ChatTable(DB)
...@@ -115,14 +115,16 @@ class UsersTable: ...@@ -115,14 +115,16 @@ class UsersTable:
def delete_user_by_id(self, id: str) -> bool: def delete_user_by_id(self, id: str) -> bool:
try: try:
# Delete User Chats # Delete User Chats
query = Chat.delete().where(Chat.user_id == id) result = Chat.delete_chats_by_user_id(id)
query.execute() # Remove the rows, return number of rows removed.
# Delete User if result:
query = User.delete().where(User.id == id) # Delete User
query.execute() # Remove the rows, return number of rows removed. query = User.delete().where(User.id == id)
query.execute() # Remove the rows, return number of rows removed.
return True return True
else:
return False
except: except:
return False return False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment