Skip to content

Order by relation aggregate (like count) #5439

@matthewmueller

Description

@matthewmueller

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

Metadata

Metadata

Assignees

Labels

kind/featureA request for a new feature.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions