ユースケース:ユーザーがまだデータベースに作成されていない場合は、作成します - ユーザーが既に存在する場合は更新します。TypeORM:保存時に 'inverseJoinColumns'プロパティが未定義です。
このロジックは機能します。 TypeORMの.save()
は、エンティティを更新したり、利用できないときに更新したりするため、このメソッドを使用します。
私の問題:作業は作成しますが、更新はしません。
this.userRepository.save(user); // user = newly created or updated entity
TypeError: Cannot read property 'inverseJoinColumns' of undefined
更新され、作成したものは、更新1は、UUID /文字列ですid
性質を持っていることであるとの唯一の違いを:これを行うときにはRelationIdLoader
からこのエラーがスローされます。
更新
@PrimaryGeneratedColumn('uuid') public id: string;
... // some columns without relations
@OneToMany(type => Finding, finding => finding.reporter)
public reportedFindings: Finding[];
@OneToMany(type => Finding, finding => finding.responsible)
public responsibleFindings: Finding[];
@ManyToMany(type => DataCenter)
public dataCenterResponsiblities: DataCenter[];
@ManyToMany(type => Finding)
public informedFindings: Finding[];
、あなたのエンティティを示しおそらくセットアップエンティティ関係が誤って – pleerock
@pleerockはちょうどそのようにした必要があります。それを見ていただきありがとうございます。 – sandrooco
'@ ManyToMany'を使用する場合は、' @ JoinTable'デコレータも置く必要があります(所有側でのみ、ここにのみ一方向の関係があるため)。 – pleerock