RLS on INSERT with linking table

Hi there,

Everyone should be able to insert into a table but only select if they have an entry in the linking table.

The issue here is that I need the team_id for the insert in the linking table (team_members).
I've been searching the internet for the answer but I can't seem to find it.

My table structure is as follows:
teams <-- team_members --> members

RLS statements on teams:
INSERT
true

SELECT
(uid() IN ( SELECT team_members.user_id
   FROM team_members
  WHERE (team_members.team_id = teams.id)))


Hopefully someone can help me with this, thanks in advance!
Was this page helpful?