<https://www.prisma.io/docs/concepts/components/pr...
# orm-help
p
https://www.prisma.io/docs/concepts/components/prisma-client/filtering-and-sorting#sort-by-relation Does this only work when the relation is 1-to-1? Am I correct in assuming the
orderBy
clause does not take into account the relations joined with
include
and
where
?
✅ 1
n
Hey @Peter 👋 You can only traverse to a to-one side using orderBy, coming from a many or one side (m -> 1, 1 -> 1)
Am I correct in assuming the
orderBy
clause does not take into account the relations joined with
include
and
where
?
You can also sort by properties of a relation. For example, the following query sorts all posts by the author’s email address
Copy code
const posts = await prisma.post.findMany({
  orderBy: {
    author: {
      email: 'asc',
    },
  },
})
Let me know if I understood your question incorrectly.