Replies: 6 comments
-
Try making an SQL query which gets at most 10 shops and then joins each of them on at most 5 products. You'll see that it becomes a really complex query which differs per DB dialect. It doesn't seem viable to support this, I haven't seen any ORM that does. I'm not sure what your use case is but it sounds pretty rare.
Basic SQL knowledge can tell you why this happens, you're joining multiple tables and returning the first two rows. If Shop 1 has Product 1 with multiple variants, it's going to return those rows.
Build it themselves with the query builder. |
Beta Was this translation helpful? Give feedback.
-
Well I don't know if it's that rare. It seems like a common use case that you'd want to limit the number of results on a relation pulled in.
Yeah, this issue is because I don't know how to do that. Thank you. |
Beta Was this translation helpful? Give feedback.
-
If you can show us the query you want in SQL, we can help you translate it to the querybuilder. If you can't, it's probably better to ask on Stackoverflow as that question isn't really related to Objection. |
Beta Was this translation helpful? Give feedback.
-
I suppose I'm hopeless, since I am clueless as to what the SQL would be |
Beta Was this translation helpful? Give feedback.
-
@nikkwong I'm facing the same issue as well. Did you find a solution? |
Beta Was this translation helpful? Give feedback.
-
I've solved this before by using a second query, applying the
|
Beta Was this translation helpful? Give feedback.
-
For example,
I notice that putting a limit on the end will limit the variants to two, and limits the products to 1, which is confusing:
I want to be able to use withGraphJoined (or maybe withGraphFetched in some circumstances) to be able to limit each level of relations. I know that the documentation says that fetching relations will hinder the use of offset/join; but I want to know what people are doing in practice to implement this kind of functionality then. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions