Complete the code to add multiple items to the array field using $push with $each.
db.collection.updateOne({ _id: 1 }, { $push: { scores: { $each: [1] } } })The $each modifier requires an array of values to add multiple items to an array field.
Complete the code to add multiple tags to a document's tags array using $push and $each.
db.collection.updateOne({ name: 'book' }, { $push: { tags: { $each: [1] } } })The $each modifier requires an array, so the tags must be inside square brackets.
Fix the error in the update command to correctly add multiple scores using $push with $each.
db.collection.updateOne({ _id: 2 }, { $push: { scores: { $each: [1] } } })The $each modifier must be followed by an array of values, which uses square brackets.
Fill both blanks to add multiple new tags and sort them in ascending order.
db.collection.updateOne({ _id: 3 }, { $push: { tags: { $each: [1], $sort: [2] } } })Use an array for $each and 1 for ascending order in $sort.
Fill all three blanks to add multiple scores, slice the array to keep only the last 3, and sort descending.
db.collection.updateOne({ _id: 4 }, { $push: { scores: { $each: [1], $slice: [2], $sort: [3] } } })$each needs an array, $slice uses negative number to keep last items, and $sort uses -1 for descending order.