Deep relation when querying
See original GitHub issueIssue type:
[x] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql
/ mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
It is possible to pass a deep relation when querying? For example, I have a User
, a User
can have many cars
and a Car
has one Make
. When I query the User
I want to get his cars
and each Car
’s Make
. I don’t want to use Eager or Lazy loading. I’m thinking something like:
$users = User.find({relations : ['cars.make']})
If no, are there any plans for implementing it in the near future? As an example, I saw this behavior in the PHP Laravel Framework
Thank you!
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (7 by maintainers)
Top GitHub Comments
I was referring to the fact that I have to explicitly write every relation like so:
But it would be nice to write it only once like so:
It’s kinda redundant to write
car
twice. If I want to remove thecars
relation I have to remove any other relation linked with thecar
too.For example, this is my current code:
A better version could be like so:
yes its supported as documentation says, did you try it?