#Counting scalar field

8 messages · Page 1 of 1 (latest)

serene iris
#

Hi everyone,
Is there an API for counting scalar fields AND relations in the same query ?

For exemple, in the following I'd like a query wher I get posts counts + colors count

model User { id Int @id @default(autoincrement()) email String @unique colors String[] posts Post[] }

Is this possible?

Thanks!

plain cipher
serene iris
#

Hi @plain cipher !

#

Yes I did, but there's no mention of counting scalar fields

serene iris
#

@plain cipher up 🙂

serene iris
#

So I know I can just fetch the whole array and count it, but isn't there an API for that ? So I would not need to fetch an array of hundreds of entries ?

#

@plain cipher

plain cipher
#

Hi @serene iris, can you please clarify the exact count you want. Do you want a count of the relation posts and a separate count of the scalar list colors?