Community Day Trivia #23: What aggregation stage processes multiple aggregation pipelines within a single stage on the same set of input documents?

We’ll be posting trivia challenges throughout the Community Day event!

The best answer for each challenge will be marked as a solution and earn the poster a promo code for $100 of Atlas credits and a Community Day 2021 Trivia Winner forum badge that can also be used as a title on the forums.

A great answer will include some information such as a link to more information or a tip on how you figured out the solution.

You can help us decide the best answer to a trivia challenge by liking great responses! To give everyone a chance at earning Atlas credits, we will use “have you already had a trivia solution accepted” to break ties in favour of those who haven’t had a solution yet.

What aggregation stage processes multiple aggregation pipelines within a single stage on the same set of input documents?

That would be $facet stage - https://docs.mongodb.com/manual/reference/operator/aggregation/facet/

Aggregation framework is a powerful feature. I have used it in place of jq and JMESPath because of it’s intuitiveness and ease of use. I know, I know, I went out of my way to import documents into MongoDB to be able to use aggregation framework but it was worth it :grinning:

Maybe the framework could be de-coupled from the core database and offered as a stand-alone tool to be able to use in other use cases. Just a suggestion.

Mahi

2 Likes

Thanks @mahisatya for the correct answer and a useful feature suggestion.

I find jq essential for command-line wrangling of JSON, but for more complicated manipulation it usually takes me less time get a result with a round trip via MongoDB aggregation than I would spend reading the jq cookbook to work out the expected syntax.

Regards,
Stennie

1 Like