I'm trying to check an equality across a referenced table.
My TS code is as follows, and I'll provide the table definitions in a moment:
const { data: { user } } = await supabase.auth.getUser();// ... various checks, user will always be defined from here onconst { data: access, error: getAccessError } = await supabase .from("access_control_list") .select("staff_id(linked_user_id), role_id(*)") .eq("staff_id.linked_user_id", user.id) .maybeSingle()
const { data: { user } } = await supabase.auth.getUser();// ... various checks, user will always be defined from here onconst { data: access, error: getAccessError } = await supabase .from("access_control_list") .select("staff_id(linked_user_id), role_id(*)") .eq("staff_id.linked_user_id", user.id) .maybeSingle()
The above query will return results where
staff_id.linked_user_id
staff_id.linked_user_id
is null, not strictly equal to
user.id
user.id
. I have had to specifically add
.not("staff_id", "is", null)
.not("staff_id", "is", null)
to the query chain to make it return only where linked_user_id equals the user's ID
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.