1

I have a situation with withGraphJoined

I have three tables Parent, Children and Friend. Parent has an One-To-Many relationship with Children and an One-To-One relationship with Friend

and now i have a query

await Parent.query()
  .withGraphJoined("children")
  .orderBy("friend.order")
  .page(1, 10)

Let's say I only have 1 Parent and it has 5 children. The query returns 5 for the total count. However, the total should be 1 because I only have 1 Parent. I know if I use page with withGraphJoined the paging will be incorrect, but if I use withGraphFetched I will have an error saying missing FROM-clause entry for table "friend"

What should I do if I really need to use page and order by friend?

Almen Wong
  • 11
  • 1

0 Answers0