id: string;
                  
                  
                      @OneToMany<CEntity>(type => CEntity, entity => entity.a)
                  
                  
                      c: CEntity[];
                  
                  
                  }
                  
                  
                  export class BEntity {
                  
                  
                      @PrimaryGeneratedColumn("uuid")
                  
                  
                      id: string;
                  
                  
                      @OneToMany<CEntity>(type => CEntity, entity => entity.b)
                  
                  
                      c: CEntity[];
                  
                  
                  }
                  
                  
                  export class CEntity  {
                  
                  
                      @ManyToOne<AEntity>(type => AEntity, entity => entity.c)
                  
                  
                      a: AEntity;
                  
                  
                      @ManyToOne<BEntity>(type => BEntity, entity => entity.c)
                  
                  
                      b: BEntity;
                  
                  
                  }
                  
                  
                  
                  
                  
                  // method in service
                  
                  
                  findOneByRelation(aEntity: AEntity, bEntity: AEntity): Promise<CEntity | undefined>{
                  
                  
                      const findOptionsWhere: FindOptionsWhere<CEntity> = {};
                  
                  
                      findOptionsWhere.a = {id: aEntity.id};
                  
                  
                      findOptionsWhere.b = {id: bEntity.id};
                  
                  
                      return this.authRepository.findOne({
                  
                  
                          where: findOptionsWhere,
                  
                  
                          relations: this.getFindOptionsRelations<CEntity>(['a', 'b']),
                  
                  
                      });
                  
                  
                  }
                  
                  
                  
                  
                  
                  // exception:
                  
                  
                  ERROR [ExceptionsHandler] Property "a, b" was not found in "CEntity". Make sure your query is correct.
                  
                  
                  
                  
                  
                  Как правильно делать выборку по отношениям?
                  
                  
                
хз, а зачем тебе ORM для чтения?
Обсуждают сегодня