nerdexam
MongoDB

C100DBA · Question #41

The following aggregation option is used to specify the specific fields that needs to be passed to the next stage of the aggregation pipeline:

The correct answer is A. $project. $project is correct because it explicitly controls which fields flow into the next pipeline stage - you can include, exclude, rename, or compute new fields, making it the dedicated "field selector" of MongoDB's aggregation pipeline. Why the distractors are wrong: B. $aggregate…

MongoDB Fundamentals

Question

The following aggregation option is used to specify the specific fields that needs to be passed to the next stage of the aggregation pipeline:

Options

  • A$project
  • B$aggregate
  • C$match
  • D$group

How the community answered

(22 responses)
  • A
    86% (19)
  • C
    5% (1)
  • D
    9% (2)

Explanation

$project is correct because it explicitly controls which fields flow into the next pipeline stage - you can include, exclude, rename, or compute new fields, making it the dedicated "field selector" of MongoDB's aggregation pipeline.

Why the distractors are wrong:

  • B. $aggregate - this doesn't exist as a pipeline stage; aggregate() is the method you call on a collection to start a pipeline, not a stage within one.
  • C. $match - filters documents based on conditions (like a WHERE clause), not which fields to pass forward.
  • D. $group - groups documents by a key and computes accumulations (like SUM, COUNT), reshaping data rather than selecting specific fields to project.

Memory tip: Think of $project like a film projector - it "projects" only what you choose onto the screen for the next stage. If $match is the filter (rows) and $group is the summarizer, $project is the column picker.

Topics

#$project#aggregation pipeline#field selection

Community Discussion

No community discussion yet for this question.

Full C100DBA Practice