P
Prisma2mo ago
syafiq

Use orderBy based on the field that is coming from nested one to many relation

Hi. Is there a way for me to use orderBy based on the field that is coming from nested one to many relations. I just saw _count when try to use orderBy in this case. I do know that we can use SQL raw query to do it but I just wondering if there is other way to it as well?
2 Replies
Nurul
Nurul2mo ago
Hey @syafiq 👋 Is your use case similar to this feature request? https://github.com/prisma/prisma/issues/8190
GitHub
Allow OrderByRelation for nested relations and support for _max, _m...
Problem Prisma is currently not able to sort array of objects at the top level by nested object properties. Also OrderByRelationAggregate is limited to _count Use case TVShow has a has-many relatio...
syafiq
syafiq2mo ago
@Nurul (Prisma) Yes it is. I saw it used js implementation to do the sorting. I try to avoid that implementation because the pagination will be corrupted.