tasks with columns id (UUID primary key), user_id (UUID), and task_description (text).tasks table.Users can select their own tasks that allows SELECT only when user_id = auth.uid().tasks with columns id (UUID primary key), user_id (UUID), and task_description (text).tasks table.Users can select their own tasks that allows SELECT only when user_id = auth.uid().tasks tabletasks with columns: id as UUID primary key, user_id as UUID, and task_description as text.Use CREATE TABLE tasks and define the columns with their types exactly as specified.
taskstasks table.Use ALTER TABLE tasks ENABLE ROW LEVEL SECURITY; to turn on RLS.
auth.uid()Users can select their own tasks on the tasks table that allows SELECT only when user_id = auth.uid().Use CREATE POLICY with the exact name and condition user_id = auth.uid().
Users can insert their own tasks on the tasks table that allows INSERT only when user_id = auth.uid().Use CREATE POLICY with the exact name and condition WITH CHECK (user_id = auth.uid()) for INSERT.
What does auth.uid() represent in Supabase row-level security policies?
auth.uid()auth.uid() is a function that returns the unique identifier of the currently logged-in user in Supabase.auth.uid() is notWhich of the following is the correct syntax to allow a user to select only their own rows in a table with a user_id column?
CREATE POLICY "Select own rows" ON my_table FOR SELECT USING ( ... );
= for comparison, not double equals ==.user_id with auth.uid()user_id column to auth.uid().Given this policy on orders table:
CREATE POLICY "Users can select own orders" ON orders FOR SELECT USING (user_id = auth.uid());
What happens if a user with auth.uid() = 'abc123' runs a query to select orders?
user_id equals the current user's ID.user_id is 'abc123'.Identify the error in this policy that aims to restrict updates to a user's own rows:
CREATE POLICY "Update own rows" ON profiles FOR UPDATE USING (user_id = auth.uid);
auth.uid is a function and must be called with parentheses: auth.uid().= is correct, user_id is the right column, and policy names can have spaces.You want to create a policy that allows users to update their own profile only if their email is verified. The profiles table has columns user_id and email_verified (boolean). Which policy condition correctly enforces this?
user_id = auth.uid() and email_verified = true must be true.Pass the test and this pattern moves unknown