Ethanxyz
07/18/2022, 7:22 PMreports
bonds
report_bonds
Reports are basically just a list of bonds, or a list of documents.
In my UI I want to display specific bond information. I know that instead of running another function, I can use something like this...
js
const { data: report, error } = await supabase
.from("reports")
.select("*, report_bonds(*)")
.eq("id", params.id)
.single();
... in hopes that it will give me back a nested obj containing all the bond information / details to render to my UI.
But, I get the error, Could not embed because more than one relationship was found for 'reports' and 'reports_bonds'
It is true that my reports_bond table has 2 FK, bond_id and report_id ( I need both ).
I have looked for answers online and in the documents but I cannot seem to get anything to work. I even tried removing 1 of the 2 FKs in the report_bond table, but I still get the same error
Any ideas on how I can go about this ?Needle
07/18/2022, 7:22 PMgaryaustin
07/18/2022, 8:01 PM.from('messages')
.select('*,test(*)'
.eq('id',7)
and I get my message id = 7 and 3 rows from test with a fk of 7 pointing to the message table.
So the reason the single key may not work is you have to flush the schema cache.garyaustin
07/18/2022, 8:21 PMselect('*, test!message_id(*)') seems to work... ! is a hint to the correct fk to use. Note I only tested the syntax on a single key, but this probably will work.Ethanxyz
07/19/2022, 1:27 AMEthanxyz
07/19/2022, 1:51 AM! mentioned in other post but I was using it wrong.