In this tutorial, we delve into creating a powerful real time Chat application using Angular 17 and Supabase. Here is the link to the tutorial on YouTube: https://www.youtube.com/watch?v=8SRhekaJ5iI
CREATETABLEpublic.users (
id uuid not nullreferencesauth.userson delete cascade,
full_name textNULL,
avatar_url textNULL,
primary key (id)
);
Enable Row Level Security
ALTERTABLEpublic.users ENABLE ROW LEVEL SECURITY;
Permit Users Access Their Profile
CREATE POLICY "Permit Users to Access Their Profile"ONpublic.users
FOR SELECT
USING ( auth.uid() = id );
Permit Users to Update Their Profile
CREATE POLICY "Permit Users to Update Their Profile"ONpublic.users
FOR UPDATE
USING ( auth.uid() = id );
Supabase Functions
CREATE
OR REPLACE FUNCTION public.user_profile() RETURNS TRIGGER AS $$ BEGININSERT INTOpublic.users (id, full_name,avatar_url)
VALUES
(
NEW.id,
NEW.raw_user_meta_data->>'full_name'::TEXT,
NEW.raw_user_meta_data->>'avatar_url'::TEXT,
);
RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
Supabase Trigger
CREATE TRIGGER
create_user_trigger
AFTER INSERT ONauth.users
FOR EACH ROW
EXECUTE PROCEDURE
public.user_profile();
Chat_Messages table (Real Time)
id (uuid)
Created At (date)
text (text)
editable (boolean)
sender (uuid)
About
In this tutorial, we delve into creating a powerful real time Chat application using Angular 17 and Supabase. Here is the link to the tutorial on YouTube: https://www.youtube.com/watch?v=8SRhekaJ5iI