I want to Run the following query using SupabaseJS
select
inspection_part.serial_no,
inspection_part.part_name,
inspection_part.requested_date_time,
inspection_part.completed_date_time,
inspection_part.status,
inspection_part.notes,
current_parts_health.parts_health
from
packages.inspection_part
join packages.current_parts_health on packages.inspection_part.serial_no = packages.current_parts_health.serial_no;
When running this query on supabase SQL editor, it works as expected, it is many to many join. But it is not working in SupabaseJS,
Here is my SupabaseJS code
const supaRes = await supabase.from("inspection_part")
.select(serial_no, part_name, requested_date_time, completed_date_time, status, notes, current_parts_health(part_health))
.eq('serial_no', 'current_parts_health.serial_no');
But I am getting the following error
“Could not find a relationship between ‘inspection_part’ and ‘current_parts_health’ in the schema cache”
looking online it appears they want me to define, primary – foreign key on the tables
I’m trying to avoid defining a foreign key relationship because it’s a many-to-many join and primary keys must be unique.
Using Nextjs 14
Tried using it without explicitly defining foreign – primary key relation but it does not work.