C100DBA · Question #47
Which of the following command inside aggregate command is used in MongoDB aggregation to filter the documents to pass only the documents that match the specified condition(s) to the next pipeline…
The correct answer is C. $match. $match is correct because it acts as a filter stage in MongoDB's aggregation pipeline, passing only documents that satisfy the specified condition(s) to the next stage - functionally similar to a WHERE clause in SQL. $aggregate (A) is not a pipeline stage at all; aggregate() is…
Question
Which of the following command inside aggregate command is used in MongoDB aggregation to filter the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.
Options
- A$aggregate
- B$sum
- C$match
- D$group
How the community answered
(27 responses)- B4% (1)
- C93% (25)
- D4% (1)
Explanation
$match is correct because it acts as a filter stage in MongoDB's aggregation pipeline, passing only documents that satisfy the specified condition(s) to the next stage - functionally similar to a WHERE clause in SQL. $aggregate (A) is not a pipeline stage at all; aggregate() is the method you call on a collection to begin the pipeline. $sum (B) is an accumulator operator used within $group to total numeric values, not to filter. $group (D) buckets documents by a specified key and computes aggregated values, but does no filtering on its own.
Memory tip: Think of $match as a "match/filter" gate - it only lets through documents that match your criteria, just like how you'd match a condition in everyday language. If you remember "$match = filter," you'll never confuse it with the accumulator or grouping stages.
Topics
Community Discussion
No community discussion yet for this question.