Filtering referenced tables

I see this example in the docs:

const { data, error } = await supabase
.from('countries')
.select( name, cities!inner ( name ) )
.eq('cities.name', 'Bali')

My example here is not returning what I expect, which would be 4 rows from the behaviors table where the goal.id match

const { data, error } = await supabase
.from('behaviors')
.select( id, goal_id, created_at, user_id, goals ( id, goal, value, category ) )
.eq('goals.id', 6)

I am getting back all behavior objects and where goals.id = 6, the goals object is there. In the behavior objects that goals.id != 6, I just get a "goals: null" ... I guess my expectation is that I would only get back the objects where goals.id was six and the other objects are filtered out.

Similar to the output of this:

const { data, error } = await supabase
.from('behaviors')
.select( id, goal_id, created_at, user_id, goals ( id, goal, value, category ) )
.eq('goal_id', 6)

However, I'd prefer to filter on the goals.category value, so confused on how to properly filter off the referenced table.
Was this page helpful?