반응형
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로 추가 조건 주고 다를 것이 없네!!
반응형