@ManyToMany

roglog·2021년 4월 1일
0

@ManyToMany


  • 다대다의 관계
  • Many-to-many에서는 @JoinTable()이 필수적이다. 두군데 중 소유하고 있는 쪽의 relation에 추가하면 된다.
  • Ex)
  @Entity()
  export class Category {
    @PrimaryGeneratedColumn()
    id: number;

    @Column()
    name: string;
  }
  @Entity()
  export class Question {
    @PrimaryGeneratedColumn()
    id: number;

    @Column()
    title: string;

    @ManyToMany(() => Category)
    @JoinTable()
    categories: Category[];
  }

https://typeorm.io/#/many-to-many-relations

profile
Full Stack Developer 📚

0개의 댓글