I create a Nest project with many generic entities. I have two abstract classes :
@Entity()
export abstract class GenericEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
name: string;
@OneToMany(() => AdditionalField, field => field.entity, {
eager: true,
cascade: true
})
additionalFields: AdditionalField[];
}
@Entity()
export abstract class AdditionalField {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
name: string;
@ManyToOne(() => GenericEntity, entity => entity.additionalFields)
@JoinColumn()
entity: GenericEntity;
}
The problem is that implementation does not work. If I extends my classes, the child classes have foreign keys of generic entities and that cause 500 error at execution. What is the best way to do that? (I have many different type of additionalFields, and many different type of generic Entities).