<@U024DS62DRC> Is there any way to return relation...
# orm-help
a
@Nurul Is there any way to return relation model field with the help of groupBy
1
Copy code
model User {
 id Int
 duration Int
 client_id Int
 Contact Contact @relation(fields: [client_id ], references: [id])
}

model Contact {
 id Int
 name String
}
I want to apply groupBy on User with client_id and need sum of duration field
But with Contact name also
@Ryan
I tried this user.groupBy( { by: ['client_id'], _sum: { duration: true, }, } )
But It is not returning a Contact name
So is there any way?
n
groupBy
doesn’t return relations at the moment. The only workaround I can think of is using raw query
a
Okay 👍