Courseiva

C100DEV MongoDB Overview and Document Model Practice Question

A developer is working with a MongoDB collection that stores sensor readings. Each document contains a timestamp, sensor ID, and a nested object 'readings' with fields like 'temperature', 'humidity', and 'pressure'. The developer needs to query for all documents where the temperature reading exceeds 30 degrees Celsius. Which query correctly retrieves these documents?

⚠ Common exam trap

A common mix-up: candidates confuse nested object queries with array queries, leading to the misuse of $elemMatch or exact subdocument matching.

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

✓

db.sensors.find( { "readings.temperature": { $gt: 30 } } )

MongoDB uses dot notation to query nested fields within documents. The query with "readings.temperature" and $gt correctly targets the nested temperature value. The other options either misinterpret the structure, use array-specific operators incorrectly, or rely on inefficient JavaScript evaluation, making them unsuitable for this scenario.

Answer analysis

Option-by-option breakdown

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

  • ✗

    db.sensors.find( { $where: "this.readings.temperature > 30" } )

    Why it's wrong here

    The $where operator allows JavaScript expressions, but it is inefficient, deprecated for most use cases, and can pose security risks. While it could technically work, it is not the recommended or correct approach for querying nested fields. The standard dot notation is preferred.

  • ✓

    db.sensors.find( { "readings.temperature": { $gt: 30 } } )

    Why this is correct

    This query uses dot notation to access the nested field 'temperature' within the 'readings' object and applies the $gt operator to find values greater than 30. Dot notation is the correct way to query nested fields in MongoDB, making this the accurate query for the scenario.

  • ✗

    db.sensors.find( { readings: { temperature: { $gt: 30 } } } )

    Why it's wrong here

    This query attempts to match an exact subdocument where the 'readings' field equals an object with a 'temperature' field containing a query operator. In MongoDB, this would look for a document where 'readings' is exactly that object, not a nested field comparison. It is incorrect for querying a nested value.

  • ✗

    db.sensors.find( { "readings": { $elemMatch: { temperature: { $gt: 30 } } } } )

    Why it's wrong here

    $elemMatch is used to match elements within an array, but 'readings' is a nested object, not an array. Using $elemMatch here would not correctly match the nested field and could lead to errors or no results. Thus, this query is incorrect for the given document structure.

About these practice questions

One of 259 original C100DEV practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.