Complete the code to add a value to the 'scores' array using $push.
db.students.updateOne({name: 'Alice'}, {$push: {scores: [1])The $push operator adds a single value to an array. Here, 95 is the value to add.
Complete the code to limit the 'scores' array to the last 3 elements after pushing a new score.
db.students.updateOne({name: 'Bob'}, {$push: {scores: {$each: [88], [1]: -3}}})The $slice modifier limits the array size after pushing. Using -3 keeps the last 3 elements.
Fix the error in the code to correctly push multiple scores and keep only the last 5.
db.students.updateOne({name: 'Carol'}, {$push: {scores: {$each: [1], $slice: -5}}})$each expects an array of values. Use square brackets [] to provide multiple scores.
Fill both blanks to push scores and keep only the first 4 elements in the array.
db.students.updateOne({name: 'Dave'}, {$push: {scores: {$each: [1], [2]: 4}}})Use $each with an array to push multiple values, and $slice with a positive number to keep the first elements.
Fill all three blanks to push a score, keep last 3 elements, and sort scores descending.
db.students.updateOne({name: 'Eve'}, {$push: {scores: {$each: [[1]], [2]: -3, [3]: -1}}})Push score 92, use $slice to keep last 3 elements, and $sort with -1 to sort descending.