SupabaseS
Supabase•4y ago
Sarcodo

RLS Policy on a link table

Hey guys, I'm trying to create a SELECT policy on a link table which links to one of the tables which has a user_id field on it. My structure looks something like this:
Link Table:
routine_id, exercise_id

Routine Table:
routine_id, ...otherColumns, user_id (FK to the auth.users table)

How can I setup a policy on the link table, something along the lines of "Show me rows in the link table where the link.routine_id joins to routine.routine_id which has a user_id of uid()"
Sorry if that's not clear, unsure how to word this 😰

Basically, I want to do the standard policy of auth.uid() = user_id but with a link to another table which contains the user_id column
Was this page helpful?