Courseiva
Aggregation Framework →easyMultiple Choice

C100DEV Aggregation Framework Practice Question

A pipeline on a `sales` collection must return only the `item` and `price` fields for all documents where `price` is greater than 50, and it should not return the `_id` field. Which pipeline achieves this?

⚠ Common exam trap

The trap here is forgetting that `_id` is included by default in a `$project` inclusion projection, so it must be explicitly excluded when not wanted.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

[ { $match: { price: { $gt: 50 } } }, { $project: { _id: 0, item: 1, price: 1 } } ]

The pipeline should filter with `$match` on `price` first, then use `$project` to include `item` and `price` while excluding `_id`. This returns only the requested fields for documents meeting the condition. Projecting before matching or using `$unset` does not satisfy the requirement to return only those two fields without `_id`.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    [ { $project: { _id: 0, item: 1, price: 1 } }, { $match: { price: { $gt: 50 } } } ]

    Why it's wrong here

    This pipeline projects first, then filters. While it may still return the correct fields, it is less efficient because `$match` after `$project` may not use the index on `price` as effectively. The aggregation optimizer can sometimes reorder these, but explicit `$match` first is preferred for performance and clarity.

  • ✗

    [ { $match: { price: { $gt: 50 } } }, { $project: { item: 1, price: 1 } } ]

    Why it's wrong here

    This pipeline filters correctly but does not exclude `_id`. In MongoDB, `_id` is included by default in projection unless explicitly set to 0. The scenario requires that `_id` not be returned, so this pipeline would include an unwanted field and fail the requirement.

  • ✓

    [ { $match: { price: { $gt: 50 } } }, { $project: { _id: 0, item: 1, price: 1 } } ]

    Why this is correct

    The `$match` stage filters documents where `price` is greater than 50, and the `$project` stage includes only `item` and `price` while explicitly excluding `_id` with `_id: 0`. This returns exactly the required fields for qualifying documents. The order is efficient because filtering happens before projection.

  • ✗

    [ { $match: { price: { $gt: 50 } } }, { $unset: ["_id", "department"] } ]

    Why it's wrong here

    The `$unset` stage removes fields but does not include only `item` and `price`. It would leave all other fields except `_id` and `department`, so the output would contain extra fields not requested. The scenario asks for only `item` and `price`, so `$project` with inclusion is the correct approach.

About these practice questions

Courseiva writes every C100DEV question from scratch — 259 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official MongoDB exam blueprint

This C100DEV practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DEV exam.