You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$count aggregation will always give you the counts for only single matching ($match) condition.
So you need to further divide your each count into multiple section and that's what the $facet provides
by processes multiple aggregation pipelines within a single stage on the same set of input documents.
프로젝트 막바지에 알게됐지만, 알게돼서 정말 다행이다!!
$facet 덕분에 하나의 쿼리에 여러 개의 파이프라인을 나열해서 한번에 여러 기준의 그룹핑 기능을 수행할 수 있었다.
찾아보니 특히 쇼핑몰처럼 다양한 기준별로 상품의 갯수를 그룹핑해서 보여주고, 특정 그룹을 또 다시 하위의 다른 기준으로
그룹핑해서 보여주는 기능에 매우 고마운 메소드인 것 같다.
이런 기능을 "Facet Query" 라 하는데,
일반적인 RDBMS에서는 하나의 쿼리로 다양한 기준의 그룹핑 쿼리를 수행할 수 없다는 아주 기분좋은 정보를 찾아냈다!!
바로 E-Commerce에 문서형 몽고디비를 사용해야하는 또 다른 중요한 이유를 찾아냈다!!
MongoDB 3.4 버전부터 $facet 스테이지를 이용해서 상품을 가격대별로 그리고 카테고리 별로 한번에 그룹핑해서 개수를 가져올 수 있다.
The text was updated successfully, but these errors were encountered: