{%- macro perm_check(user="$[user_id]", team="$[team_id]", action="'read'", table) -%}
EXISTS (
SELECT 1
FROM permissions
WHERE user_id = {{ user }}
AND team_id = {{ team }}
AND action = {{ action }}
AND object_type = {{table}}
)
{%- endmacro perm_check -%}