小编Roa*_*ach的帖子

如何对 typeorm 关系进行递归

类别.ts

@Entity('categoryenter code here')
export class Category{
  @PrimaryGeneratedColumn({ type: 'int' })
  id: Category;

  @OneToMany(() => Category, category => category.category,{eager:true})
  categoryList: Category[];

  @ManyToOne(() => Category, (category) => category.categoryList)
  category: Category;
}
Run Code Online (Sandbox Code Playgroud)

类别实体在上面(mysql)。我想找到一个包含所有这样子项的类别

await categoryRepo.findOne({
  where:{ id: 1 },
  relations:['categoryList']
})
Run Code Online (Sandbox Code Playgroud)

但我得到了一个错误Maximum call stack size exceeded

我该怎么办

node.js typescript typeorm nestjs

5
推荐指数
2
解决办法
6247
查看次数

标签 统计

nestjs ×1

node.js ×1

typeorm ×1

typescript ×1