title: Join Tables in TypeORM & NodeJS
body: <p>I created to TypeORM Entities Category and Subcategory</p>
  
  <p><strong>Category.ts</strong></p>
  
  <pre><code>@Entity()
  export class Category {
  
    @PrimaryGeneratedColumn()
    id: number;
  
    @Column()
    name: string;
  
    @Column()
    description: string;
  
    @OneToMany(() =&gt; Subcategory, (subcategory) =&gt; subcategory.category)
    public Subcategories: Subcategory[];
  
    @OneToMany(() =&gt; Item, (item) =&gt; item.category)
    public Items: Item[];
  
  }
  </code></pre>
  
  <p><strong>Subcategory.ts</strong> </p>
  
  <pre><code>import {
    Entity,
    PrimaryGeneratedColumn,
    Column,
    ManyToOne,
    OneToMany,
    CreateDateColumn,
    UpdateDateColumn
  } from "typeorm";
  import {Category} from "./Category";
  import {Item} from "./Item";
  
  @Entity()
  export class Subcategory {
  
    @PrimaryGeneratedColumn()
    id: number;
  
    @Column()
    name: string;
  
    @Column()
    description: string;
  
    @ManyToOne(() =&gt; Category, (category) =&gt; category.Subcategories)
    public category: Category;
  
    @OneToMany(() =&gt; Item, (item) =&gt; item.subcategory)
    public Items: Item[];
  
  }
  </code></pre>
  
  <p>Get Category Query on TypeScript : </p>
  
  <pre><code>await getRepository(Category).find();
  </code></pre>
  
  <p><strong>Issue:</strong> </p>
  
  <p>I couldn't find a way online to include the Subcategories into the getCategory query, I just one to perform a simple join that will get me All the categories and their subcategories. In entity framework I used to something like Category.Includes(Subcategories) and it does the job.</p>
  
  <p>Is there any easy/simple way to join tables in TypeORM / NodeJS ? </p>
  
  <p>Thanks a lot for taking the time to read my question, I appreciate it!</p>