C100DBA · Question #35
Which of the following is true about aggregation framework?
C is correct. Pipeline expressions in MongoDB's aggregation framework process each document independently and carry no memory of previous documents - they are stateless. The only exception is accumulator expressions ($sum, $avg, $push, etc.) used within the $group stage, which…
Question
Which of the following is true about aggregation framework?
Options
- AEach aggregation operator need to return atleast one of more documents as a result
- Bthe aggregate command operates on a multiple collection
- CPipeline expressions are stateless except accumulator expressions used with $group operator
Explanation
C is correct. Pipeline expressions in MongoDB's aggregation framework process each document independently and carry no memory of previous documents - they are stateless. The only exception is accumulator expressions ($sum, $avg, $push, etc.) used within the $group stage, which must track state across multiple documents to compute their results.
A is wrong because operators like $match or $limit can reduce the pipeline output to zero documents - there is no minimum return requirement.
B is wrong because the aggregate command operates on a single collection. While $lookup can pull in data from other collections within the pipeline, the command itself is invoked on one collection.
Memory tip: Think of pipeline stages as an assembly line - each worker (stage) handles one item (document) at a time without remembering past items, except the "accountant" ($group accumulators) who must keep a running tally across all items.
Topics
Community Discussion
No community discussion yet for this question.