Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order by relation aggregate (like count) #5439

Closed
matthewmueller opened this issue Feb 3, 2021 · 3 comments · Fixed by prisma/prisma-engines#1700
Closed

Order by relation aggregate (like count) #5439

matthewmueller opened this issue Feb 3, 2021 · 3 comments · Fixed by prisma/prisma-engines#1700
Assignees
Labels
kind/feature A request for a new feature. team/client Issue for team Client.
Milestone

Comments

@matthewmueller
Copy link
Contributor

matthewmueller commented Feb 3, 2021

Problem

We support ordering by a relation field, but not order by a relation aggregate.

For example: get all users, order by post count.

prisma.user.findMany({
  orderBy: {
    posts: { 
      count: 'asc'
    }
  }
})

Additional context

@xbjfk
Copy link

xbjfk commented Jan 23, 2023

Is there an equivalent for the other aggregates such as max, min and avg, or should I open a new issue?

@janpio
Copy link
Member

janpio commented Jan 24, 2023

Definitely a new issue if this does not exist yet.

@egeste

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. team/client Issue for team Client.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants