'Applying a row-level-security policy on a view [duplicate]

I'm a bit new to the whole Supabase thing. I'm trying to apply a policy to a view that I created. I'm not sure if it's even possible but I can't see why it wouldn't be. I don't think that this question is a duplicate of this question because of the Supabase aspect.

I tried to use the following example but instead of using a table, I used a view.

create policy "Team members can update team details if they belong to the team."
  on teams_view
  for select using (
    auth.uid() in (
      select user_id from members
      where team_id = id
    )
  );

Unfortunately, postgresql complains that "teams_view" is not a table, which is ofcourse correct. The question is: is there a correct way of applying a policy on views and if so, how would this look like?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source