-
-
Save dani-z/b74b3bcaf2359d920107bc218625ff55 to your computer and use it in GitHub Desktop.
Prisma is awesome. I love this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getMostPopularPostSlugs({ | |
limit, | |
exclude, | |
}: { | |
limit: number | |
exclude: Array<string> | |
}) { | |
const result = await prisma.postRead.groupBy({ | |
by: ['postSlug'], | |
_count: true, | |
orderBy: { | |
_count: { | |
postSlug: 'desc', | |
}, | |
}, | |
where: { | |
postSlug: {notIn: exclude}, | |
}, | |
take: limit, | |
}) | |
return result.map(p => p.postSlug) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment