MongoDB: How to count distinct values in arrays while grouping in an aggregation stage
I have an aggregation pipeline in which I'm trying to find the unique values within an array property and also the number of instances of each value within each document's array. I arrive at a stage where the documents look…