Skip to content

Joining tables to retrieve data #3379

Answered by dshukertjr
praj18 asked this question in Questions
Discussion options

You must be logged in to vote

Hi @praj18!

I noticed that you are using single() on the query of domains. 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?

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]',
      ...
    },
  ]
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@praj18
Comment options

Answer selected by praj18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants