Reputation: 635
With Prisma, I'm trying to join an indirectly referenced table onto a query, see SQL example below which represents the basic use case. Lets say in the example, that I want to access the companyCar table from the companyUser table. I can think of 2 ways to do this, via joining using the company table, or by directly comparing the companyId of the 2 tables
option 1, follows foreign key references
SELECT * FROM CompanyUser companyuser
JOIN Company company on company.Id = companyuser.companyId
JOIN CompanyCar companycar on companycar.companyId = company.Id
option 2, does not directly follow foreign key references
SELECT * FROM companyUser companyuser
JOIN CompanyCar companycar on companycar.companyId = companyuser.companyId
How do I solve this within the prisma framework using includes or some other mechanism?
Upvotes: 1
Views: 742
Reputation: 635
I recieved a response from one of the devs on github. See the link below stating that currently a rawQuery must be used, but this feature is an outstanding feature request.
https://github.com/prisma/prisma/discussions/14905
Upvotes: 1