I'm creating a project in NestJS, TypeORM and Postgres, for a job at college, but in a specific case the TypeORM is giving me the following error relatedEntities.forEach is not a function
This is Patient Entity
@Entity()
@Unique(['cpf'])
export class Patient extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({ nullable: false, type: 'varchar', length: 100 })
name: string;
@Column({ nullable: false, type: 'varchar', length: 255, select: false })
password: string;
@Column({ nullable: false, type: 'char', length: 11 })
cpf: string;
@OneToMany(() => MedicalRecord, medicalRecord => medicalRecord.patient)
medicalRecord: MedicalRecord[];
}
This is the MedicalRecord
@Entity()
export class MedicalRecord extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({ nullable: true, type: 'text' })
diseaseHistory: string;
@Column({ nullable: true, type: 'text' })
medicines: string;
@ManyToOne(() => Patient, patient => patient.medicalRecord)
patient: Patient;
}
If I create or list MedicalRecords it works, but the error happens when I try to create a new Patient