반응형
  async prDetail(productId: number) {
    const detail = await this.productRepository
      .createQueryBuilder('products')
      .leftJoinAndSelect('products.category', 'category')
      .leftJoinAndSelect('products.images', 'images')
      .where(`products.id = :id`, { id: productId })
      // .andWhere(`status = :status`, { status: 'sale' })
      .getMany();

    return detail;
  }

Join을 하는데 쿼리가 드러운것도 있고 앞으로 쿼리빌더로 바꾸고 싶은 부분도 있어서 새로 제작해야 하는 api에 쿼리 빌더를 써봤는데...

생각보다 좋은것 같다. 조인할 것 붙이고 where로 제한주고 andWhere로 추가 조건 주고 다를 것이 없네!!

반응형

'취업전 끄적 > 개발일지' 카테고리의 다른 글

3/21  (0) 2023.03.21
3/20  (0) 2023.03.20
3/13  (0) 2023.03.13
3/9 최종#7  (0) 2023.03.09
3/8 최종 기억안남  (0) 2023.03.08

+ Recent posts