Skip to content

Best way to get foreign table's count? #669

Discussion options

You must be logged in to vote

Hey @imtaehyun,

For now it's only possible to get the count through the array.

Later on it'll be possible to "flatten" the embedded resource so you can get the count like:

let { data: notes, error } = await supabase
          .from("notes")
          .select(
            `
          id,
          title,
          description,
          createdAt,
          commentsCount:comments(count)->count`
          )

const commentsCount = note.commentsCount

Pending enhancement tracked on: PostgREST/postgrest#1233 (comment)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kiwicopple
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants