Complete the code to remove all elements equal to 5 from the 'scores' array.
db.students.updateOne({name: 'Alice'}, {$pull: {scores: [1])The $pull operator removes all instances of the specified value from the array. Here, 5 is the value to remove.
Complete the code to remove all elements greater than 10 from the 'grades' array.
db.courses.updateMany({}, {$pull: {grades: { [1]: 10 }}})$lt removes elements less than 10, which is wrong here.$eq removes only elements equal to 10.The $gt operator means 'greater than'. It removes all elements greater than 10.
Fix the error in the code to remove all elements less than or equal to 3 from the 'values' array.
db.data.updateOne({}, {$pull: {values: { [1]: 3 }}})$lt excludes elements equal to 3.$gte removes elements greater than or equal to 3, which is opposite.The $lte operator means 'less than or equal to', which matches the requirement.
Fill both blanks to remove all elements that are strings equal to 'remove' from the 'tags' array.
db.collection.updateMany({}, {$pull: {tags: { [1]: [2] }}})$ne removes elements not equal to the value, which is wrong.The $eq operator matches elements equal to the given value. The value must be a string, so quotes are needed.
Fill both blanks to remove all elements from the 'items' array where the 'price' field is less than 20.
db.store.updateOne({id: 1}, {$pull: {items: { [1]: { [2]: 20 }}}})cost instead of price as field name.$gt instead of $lt operator.The field to check is price. The operator for 'less than' is $lt. The query removes items with price less than 20.