Daniel Norman
2.21.0
, now you can!
const userRatingsCount = await prisma.user.groupBy({
by: ['city'],
count: {
city: true,
},
orderBy: {
_count: {
city: 'desc',
},
},
})
The query returns the following:
[
{ city: 'Berlin', count: { city: 3 } },
{ city: 'Paris', count: { city: 2 } },
{ city: 'Amsterdam', count: { city: 1 } },
]
Enable this feature with the orderByAggregateGroup
preview flag:
generator client {
provider = "prisma-client-js"
previewFeatures = ["orderByAggregateGroup"]
}
📚 Learn more in the release notes
For more info and links to documentation, you can read the release notes.
🚢 The next 2.22.0 release will be postponed by a week
We release Prisma normally every two weeks. The next 2.22.0
release will be postponed by a week and happen on May 5, 2021.
🌳 Help us spread the word about Prisma and we’ll donate trees 🌳
To help spread the word about Prisma, we’d very much appreciate if you would star the repo 🌟 And if you’re excited about the features in this week’s release, then help us and share your excitement on Twitter.
Quick reminder that for every tweet tagging Prisma in the month of April, we’ll be donating a tree as part of Tweets for Trees .
📺 Join us on Thursday for the “What’s new in Prisma” livestream
This week, my colleague @ryan and I will discuss the latest release and other news from the Prisma ecosystem in a on Thursday at 5pm Berlin | 8am San Francisco.
🙏 Big thanks to all the external contributors who helped with this release!