Q: I want to create a self-related table in typeorm using nestjs I need an entity to have following columns:
    Category:{ division_id:int cat_id:int cat_name:varchar }
I also want to self-related a column inside it to have parent category for some categories, so I created the entity below:
`import { ApiProperty } from '@nestjs/swagger';
import { BaseEntity } from '../embeded/base.type';
import { Commodity } from './commodity.entity';
import { Division } from '../public/division.entity';
import {
Entity,
Column,
ManyToOne,
JoinColumn,
OneToMany,
PrimaryColumn,
PrimaryGeneratedColumn,
ManyToMany,
} from 'typeorm';
@Entity()
export class Category extends BaseEntity {
  @ApiProperty()
  @PrimaryColumn()
  division_id: number;

  @ManyToOne(() => Division, (division) => division.categories, {
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  @JoinColumn({ name: 'division_id', referencedColumnName: 'division_id' })
  division: Division;

  @PrimaryGeneratedColumn()
  cat_id: number;

  @ApiProperty()
  @Column()
  cat_name: string;

  @ApiProperty()
  @Column()
  parent_id: number;

  @ManyToOne(() => Category, (category) => category.sub_category, {
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  @JoinColumn([{ name: 'parent_id', referencedColumnName: 'cat_id' }])
  @ApiProperty({ type: () => Category, required: false })
  parent_category: Category;

  @OneToMany(() => Category, (category) => category.parent_category)
  sub_category: Category[];

  @ManyToMany(() => Commodity, (commodity) => commodity.categories)
  commodities: Commodity[];
}`     

But I got this error:
there is no unique constraint matching given keys for referenced table "category"
