Policy to check user belongs to team

Hi, there! Noob question: I want to check if this user belongs to the team which owns the site so the user can select/update etc. I have a Sites table with a "team" property (foreign key to Team id), Teams table, and finally a Members table, with "user_id" and "team". I can't seem to find any good example on creating a policy which looks up "Members" to check whether the currently logged in user belongs to the team which is referenced in the "team" property.

My feeble attempt does not work:

(EXISTS ( SELECT m.user_id,
    m.team
   FROM "Members" m
  WHERE ((m.team = team) AND (m.user_id = uid()))))


Do I have to INNER JOIN?
Was this page helpful?