Nested relation query help
Hello, I was trying to query users, then I added the implementation to show payments but now I realize it was bringing payments of all users from the membership instead of bringing all payments of that specific user for each specific membership. Is there a way to do this query in the same object or is there a way to reference the current user for each index of the array?
Example of what It would be ideal but ofc it doesn't work
3 Replies
@Fervore Would you post your
schema.prisma
?hello @moosthuizen, thanks for reaching out, here are the models in question from the schema.prisma
@Fervore Seeing as there is a relation between
Member
and Payment
, would the following work?
You can then flatten result[].payments[].membership
into result[].new_property_with_membership_and_payment_fields
or similar
Alternatively, my recommendation is to use the first query you listed above, and do the filtering you want in code.