Joining tables to retrieve data #3379
-
I have two tables, one for domains and one for webpages where:
I want to be able to do the following using supabase-js:
I've tried various solutions, however, I can't seem to get it to work.
I don't think using promises is the ideal way of doing this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @praj18! I noticed that you are using In that case, could you try the following code and let me know how it goes? const { data, error } = await supabase
.from('domains')
.select(`
*,
webpages (*)
`)
.eq('domain_uid', id)
.single() This should return results in the form of {
id: '[domain_id]',
domain_name: '[domain_name]',
...
webpages: [
{
id: '[webpage_id]',
domainn_id: '[domain_id]',
...
},
{
id: '[webpage_id]',
domainn_id: '[domain_id]',
...
},
]
} |
Beta Was this translation helpful? Give feedback.
Hi @praj18!
I noticed that you are using
single()
on the query ofdomains
. Could I assume that in this case you only want single record for domain, and you have multiple webpages?In that case, could you try the following code and let me know how it goes?
This should return results in the form of