`result = *await* client*.*prisma*.*invites*.group...
# orm-help
l
result = *await* client*.*prisma*.*invites*.groupBy*({
        
by: ["inviterId"],
        
_count: {
          
inviterId: *true*,
        
},
        
orderBy: {
          
_count: {
            
inviterId: 'desc',
          
},
          
where: {
            
serverId: message*.*guildID,
            
valid: *true*,
          
},
        
},
      
});
Hi, I'm not sure if someone could help me. But I'm currently trying to order this by highest to lowest numbers. But im getting an error which im not sure how to get by.
Copy code
Type '{ _count: { inviterId: string; }; where: { serverId: string | undefined; valid: true; }; }' is not assignable to type 'Enumerable<invitesOrderByInput> | undefined'.
  Object literal may only specify known properties, and '_count' does not exist in type 'Enumerable<invitesOrderByInput>'
r
Hi @Logan - What version of prisma are you running?
orderByAggregateGroup
is only available in
2.21.0
and up
l
Im currently on v2.23.0
r
so that's not it then 😄
l
Dang! Would have been a simpler fix haha
r
aah - is your "where" inside your "orderBy"?
Copy code
result = await client.prisma.invites.groupBy({
        by: ["inviterId"],
        _count: {
          inviterId: true,
        },
        orderBy: {
          _count: {
            inviterId: 'desc',
          },
         
        },
        where: {
            serverId: message.guildID,
            valid: true,
          },
      });
that maybe? (not sure if it's a copy/paste error though)
l
That was a mistake from me Thanks for pointing that out 🙂 . But, I still get:
Copy code
Type '{ _count: { inviterId: string; }; }' is not assignable to type 'Enumerable<invitesOrderByInput> | undefined'.
  Object literal may only specify known properties, and '_count' does not exist in type 'Enumerable<invitesOrderByInput>
r
do you have `
previewFeatures = ["orderByAggregateGroup"]
set in your
schema.prisma
file?
l
Not sure, I'll have a look.
r
you'd still need that set, even on your version
until it comes out of preview
l
That wasn't there. Just added it. However, I'm still getting the same error.
Copy code
generator client {
  provider = "prisma-client-js"
  previewFeatures = ["orderByAggregateGroup"]
}
r
you'd need to run the "generate" again after adding it
prisma generate
that ..should.. fix the issue ..
l
Thanks! Error is gone. Thanks a tonn!
r
Awesome, glad it worked!
l
🙂