Issue retrieving related data corresponding to each ViewEntity #236
Unanswered
MateoGuerreroE
asked this question in
Q&A
Replies: 1 comment
-
Update: Looks like creating a QueryService that filters the received results for the relation works fine for solving this issue. My question now is: is this how It's supposed to be done or the raw relation should be working without a query service? For now It's solved, I'm leaving the comment in case someone else encounters this issue, the info on this discussion: doug-martin/nestjs-query#1002 was used for solving this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Been a while trying to find what I'm doing wrong:
So I'm working with view entities, and filtering or retrieving one with related data works fine, but whenever I want to retrieve all parent entities and include related data, those entities who have related data will have, in their relation attribute, an array with all of the related data from all queried entities, not only the data corresponding to each parent entity.
As an example:
I have a view Entity named "users", which is related one-to-many "tags". Having 30 users, and from those users only 5/30 have tags related, If I retrieve all users, in those users who have tags, will return in their "tags" attribute an array of all tags found from all 5 users, not only the tags related to each. So It's looking something like this the result:
Btw, filtering works fine, If I filter in that example which entities have the "tag2", and It happens to be only user with Id 6, It will only return user with Id 6, and on their "tags" attribute will only have their corresponding tag. If, for example, I set a tag filter that returns 2 entities, will return those 2 entities but each of them will have an array with both tags.
Add to this that sometimes I'm getting in some entities which have related data, the full array twice. I've been trying to check what may be causing the issue but haven't found any, tried with auth scope (But It will scope the whole SQL query when retrieving relation info), but I've not found an answer yet, neither could find an issue related here. May be something small I'm not considering?
Beta Was this translation helpful? Give feedback.
All reactions