nerdexam
MongoDB

C100DBA · Question #85

Which of the following operators is used to updated a document partially?

The correct answer is A. $set. $set is MongoDB's partial update operator - it modifies only the specified fields in a document while leaving all other fields untouched, making it the correct choice for a partial update. $update does not exist in MongoDB; it's a common distractor that confuses the operator name

MongoDB Fundamentals

Question

Which of the following operators is used to updated a document partially?

Options

  • A$set
  • B$update
  • C$project
  • D$modify

How the community answered

(34 responses)
  • A
    88% (30)
  • B
    3% (1)
  • C
    6% (2)
  • D
    3% (1)

Explanation

$set is MongoDB's partial update operator - it modifies only the specified fields in a document while leaving all other fields untouched, making it the correct choice for a partial update.

$update does not exist in MongoDB; it's a common distractor that confuses the operator name with the updateOne()/updateMany() method names. $project is an aggregation pipeline stage used to include or exclude fields in query results, not to modify stored documents. $modify is also not a valid MongoDB operator - it's invented to sound plausible.

Memory tip: Think of $set like setting a value on an object in code (obj.field = value) - you're targeting and changing only what you name, nothing else.

Topics

#$set operator#partial update#update operators

Community Discussion

No community discussion yet for this question.

Full C100DBA Practice