[Question] Is it possible to include Nth-level relationship data using find options?
Problem
If I have a Person entity with a one-to-many relationship with a Home entity, and then the Home entity has a many-to-one relationship with a HomeType entity, is there a way to get the Home entities to include their HomeType data when selecting Person's and including their Home relations? `let personsWithHomes = await Person.find({ where: { id: id }, relations: ["homes"] })` This would return my Person records with their associated Home records, but the Home records do not include their associated HomeType. I tried adding the type as an eager loaded relationship, but it still does not get included. Is there a way to specify the sub relations to include? `let personsWithHomes = await Person.find({ where: { id: id }, relations: ["homes", "homes.homeType"] })`
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: [Question] Is it possible to include Nth-level relationship data using find options?
I added more advanced support to `relations` of the find options, e.g. [code block] It was a hard feature to implement, because sub-relations can be joined via embeds, but I did it ;) This feature will be available in `0.1.7`. Contributions to docs are welcomed.
Trust Score
12 verifications
- 1
I added more advanced support to `relations` of the find options, e.g.
I added more advanced support to `relations` of the find options, e.g.
- 2
It was a hard feature to implement, because sub-relations can be joined via embe
This feature will be available in `0.1.7`. Contributions to docs are welcomed.
Validation
Resolved in typeorm/typeorm GitHub issue #1270. Community reactions: 406 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep