I have two entities Document and DocumentVersion, they have a one to many relation (one Document has many DocumentVersions).
Document:
@Entity()
@TableInheritance({ column: { type: 'varchar', name: 'type' } })
export class Document {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@OneToMany(() => DocumentVersion, version => version.document)
versions: DocumentVersion[];
...
}
DocumentVersion:
@Entity()
@TableInheritance({ column: { type: 'varchar', name: 'type' } })
export class DocumentVersion {
@PrimaryGeneratedColumn()
id: number;
@Column()
isAuthorUpdate: boolean;
@ManyToOne(() => Document, document => document.versions)
document: Document;
...
}
I am using NestJS with Typeorm and when I call repo.find({ relations: { versions: true }}), I get the following error:
TypeError: Cannot read properties of undefined (reading 'joinColumns')
From my research it seems that error occurs when both sides of the relations are not defined (i.e. only the @ManyToOne side is defined), but I have both sides defined.
The underlying database is Postgres if that matters.