首页 > 解决方案 > 获取 typeORM 中实体的关系列表?

问题描述

我正在使用带有 typeORM 的存储库模式。对于下面这样定义的实体

@Entity()
export class Apple extends BaseEntity {
  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  createdDate: Date;

  @ManyToOne((type) => xyz, (xyz) => xyz.fruit)
  @JoinColumn({ name: 'fruit' })
  fruit: Fruit;

  @ManyToOne((type) => ABC, (abc) => abc.juice)
  @JoinColumn({ name: 'juice' })
  juice: Juice;
 
}

有没有办法获取所有关系的列表,即像格式 ['fruit','juice'] 这样的数组

标签: node.jstypeorm

解决方案


推荐阅读