import {
  Entity, ManyToOne, JoinColumn, PrimaryColumn
} from 'typeorm';
import { Parents } from './parents.entity';
import { Children } from './children.entity';

@Entity('enfants_parents', { schema: 'public' })
export class ParentsChildren {
  @PrimaryColumn('uuid', { name: 'id_parent' })
  parentId: string;

  @PrimaryColumn('uuid', { name: 'id_enfant' })
  enfantId: string;

  @ManyToOne(() => Parents, p => p.parentChildren, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'id_parent', referencedColumnName: 'user_id' })
  parent: Parents;

  @ManyToOne(() => Children, c => c.parentLinks, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'id_enfant', referencedColumnName: 'id' })
  child: Children;
}
