A. The field name must be a string key with a value, not just a key
B. You cannot use $unset with updateMany
C. The collection name is incorrect
D. The $unset operator requires an array of fields
Solution
Step 1: Check $unset syntax
The $unset operator requires field names as keys with a value (usually 1) to specify removal.
Step 2: Identify missing value
In the command, { $unset: { "status" } } is invalid because the field "status" has no value.
Final Answer:
The field name must be a string key with a value, not just a key -> Option A
Quick Check:
$unset needs field: value pairs [OK]
Hint: Always provide a value (like 1) with field names in $unset [OK]
Common Mistakes:
Omitting the value for the field in $unset
Using $unset with wrong update method
Assuming $unset accepts arrays
5. You have documents in employees collection with fields name, age, department, and tempField. You want to remove tempField only from employees in the Sales department without affecting others. Which command achieves this?