Complete the code to update the field 'score' only if the new value is less than the current value using the $min operator.
db.collection.updateOne({ _id: 1 }, { $[1]: { score: 50 } })The $min operator updates the field only if the specified value is less than the current field value.
Complete the code to update the field 'score' only if the new value is greater than the current value using the $max operator.
db.collection.updateOne({ _id: 2 }, { $[1]: { score: 80 } })The $max operator updates the field only if the new value is greater than the current value.
Fix the error in the update command to use the correct operator that updates 'level' only if the new value is greater.
db.collection.updateOne({ _id: 3 }, { $[1]: { level: 10 } })To update only if the new value is greater, use $max. Using $min or $set would not achieve this.
Fill both blanks to update 'score' to 40 only if it is less than current, and 'rank' to 5 only if it is greater than current.
db.collection.updateOne({ _id: 4 }, { $[1]: { score: 40 }, $[2]: { rank: 5 } })Use $min to update 'score' only if 40 is less than current, and $max to update 'rank' only if 5 is greater than current.
Fill all three blanks to update 'score' to 30 if less, 'level' to 15 if greater, and 'rank' to 2 if less.
db.collection.updateOne({ _id: 5 }, { $[1]: { score: 30, rank: 2 }, $[2]: { level: 15 }, $[3]: { extra: 100 } })Use $min for 'score' and 'rank' to update if new values are less, $max for 'level' to update if greater, and $set for 'extra' to always update.