Skip to content

Commit

Permalink
feat: add function to check if username is taken
Browse files Browse the repository at this point in the history
Signed-off-by: Raphael Arce <raphael.arce@ts.berlin>
  • Loading branch information
raphael-arce committed Oct 14, 2024
1 parent 4f8bcf6 commit bd6ca79
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE OR REPLACE FUNCTION is_username_taken(given_username text)
RETURNS BOOLEAN AS $$
DECLARE
is_username_taken BOOLEAN;
BEGIN
-- Check if the username exists in the profile table
SELECT EXISTS(SELECT 1 FROM public.profiles WHERE username = given_username) INTO is_username_taken;

-- Return the result
RETURN is_username_taken;
END;
$$
LANGUAGE plpgsql
SECURITY DEFINER;

0 comments on commit bd6ca79

Please sign in to comment.