Hey, I would like to count COUNT relations per eac...
# help
v
Hey, I would like to count COUNT relations per each row (
albums
) has. Is this possible to do in one query? So basically I want to get known how many
images
each
albums
record has
Copy code
js
const { data } = await supabaseClient
  .from("albums")
  .select(
    `
    name,
    created_at,
    images (*)
    `)
  .limit(3, { foreignTable: "images" });
n
Hello @venus! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
🆕 Count relationship records
g
images(count) in the select probably gets you close to what you want. But then you can't do images(*) I don't think, although if you really are getting all the images you can just count the array returned there.
n
Count relationship records
v
I realized I don't need to get them at all, so I can use
images(count)
instead. Thanks