FG
๐Ÿ’ป Software๐Ÿ—„๏ธ Databases

[Question] Is it possible to include Nth-level relationship data using find options?

Freshover 8 years ago
Mar 14, 20260 views
Confidence Score81%
81%

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

Canonical Fix
High Confidence Fix
76% confidence93% success rate12 verificationsLast verified Mar 14, 2026

Solution: [Question] Is it possible to include Nth-level relationship data using find options?

Low Risk

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.

76

Trust Score

12 verifications

93% success
  1. 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. 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

Worked: 12
Partial: 2
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

typeormormtypescriptquestioncomp:-query-builder