Skip to content

Commit dc51ef2

Browse files
committed
Implement unfollow function to remove a follow relationship between two users in the database
1 parent bf67ea7 commit dc51ef2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

backend/data/follows.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ def follow(follower: User, followee: User):
2121
pass
2222

2323

24+
def unfollow(follower: User, followee: User):
25+
"""Remove a follow relationship between two users."""
26+
with db_cursor() as cur:
27+
cur.execute(
28+
"DELETE FROM follows WHERE follower = %s AND followee = %s",
29+
(follower.id, followee.id),
30+
)
31+
2432
def get_followed_usernames(follower: User) -> List[str]:
2533
"""get_followed_usernames returns a list of usernames followee follows."""
2634
with db_cursor() as cur:

0 commit comments

Comments
 (0)