You need a foreign key constraint on the user_uplo...
# help
m
You need a foreign key constraint on the user_uploaded_contents table. Then you can use this:
Copy code
js
supabase.from("user_public").select("*, contents:user_uploaded_contents(*)")
If you are getting a could not find a relationship, be sure to add a foreign key on the user_uploaded_contents table for the user_public table.
z
contents:user_uploaded_contents(*)
i never understood this syntax can you please explain it to me?
h
I could do such direct relationship, but I wondered if I can do it indirectly using user_id cause it simplifies inserting. but if it's not possible so be it. maybe I'll use stored procedure
m
:()
Because I have many relationships in my database I tend to use this
z
can be any name?
m
:()
Name can be anything
z
right
so in u give it a comma seperated list of column names
like usual?
h
nevermind, I didn't know that table 'user_uploaded_content' can refer to the same 'user_id' column on 'user_public'. I thought I had to refer user_public.id
m
A more advanced example
Copy code
typescript
  const [data] = await supabase
    .from("activities")
    .select(
      `*, 
      result:activity_flow_${mode}_results(*),
      nodes:activity_flow_node_${mode}_results(*, node:flow_nodes(*)),
      node_statistics:activity_flow_node_${mode}_statistics(node_id, statistic),
      tries:activity_flow_try_${mode}_results!activities_tries_activity_id_fkey(*, 
      last_node_tries:flow_node_${mode}_tries!flow_node_tries_try_id_fkey(*))`
    )
z
so if u wanted to use
node_id
later in ur query
u would do
node_statistics.node_id
?