Complete the code to remove the field 'age' from all documents.
db.collection.updateMany({}, [1])The $unset operator removes the specified field from documents. Using { $unset: { age: "" } } removes the 'age' field.
Complete the code to remove the 'address' field from documents where 'status' is 'inactive'.
db.collection.updateMany({ status: "inactive" }, [1])To remove the 'address' field only from documents with status: 'inactive', use $unset with the field name.
Fix the error in the code to correctly remove the 'phone' field from all documents.
db.collection.updateMany({}, { $unset: { phone: [1] } })The $unset operator requires the field to be set to an empty string "" to remove it.
Fill both blanks to remove 'email' and 'username' fields from documents where 'active' is false.
db.collection.updateMany({ active: false }, { $unset: { [1]: "", [2]: "" } })To remove multiple fields, list each field with an empty string value inside $unset.
Fill all three blanks to remove 'city', 'state', and 'zip' fields from documents where 'country' is 'USA'.
db.collection.updateMany({ country: "USA" }, { $unset: { [1]: "", [2]: "", [3]: "" } })To remove multiple fields, list each field with an empty string value inside $unset. Here, 'city', 'state', and 'zip' are removed.