How could I write the following query in JS?

I'm having difficulties translating this query:

SELECT location.name
FROM location
JOIN facility
    ON location.id = facility.location_id
JOIN facility_category
    ON facility_category.id = facility.facility_category_id
    WHERE facility_category.name = 'Imaging Center'


So far I have something likke this:

.from('location')
      .select('name, facility!inner(*), facility_category(*)')
      .eq('facility_category.name', 'Imaging Center')


But I just get the follwing error: "Could not find a relationship between 'location' and 'facility_category' in the schema cache", even though the query works fine in the SQL editor.

Also, I'd like to make it distinct, but my understanding is that it is not possible via the API?
Was this page helpful?