Complete the code to add a new tag 'urgent' to the tags array in the document.
db.tasks.updateOne({ _id: 1 }, { [1]: { tags: 'urgent' } })The $push operator adds a value to an array field. Here, it adds 'urgent' to the tags array.
Complete the code to add the number 5 to the scores array in all documents where the name is 'Alice'.
db.students.updateMany({ name: 'Alice' }, { [1]: { scores: 5 } })$push adds the value 5 to the scores array for all matching documents.
Fix the error in the code to correctly add 'completed' to the status array for the document with _id 10.
db.orders.updateOne({ _id: 10 }, { [1]: { status: 'completed' } })The $push operator correctly adds 'completed' to the status array. Using $set would replace the field.
Fill both blanks to add multiple tags 'new' and 'sale' to the tags array in one update.
db.products.updateOne({ _id: 5 }, { [1]: { tags: { [2]: ['new', 'sale'] } } })$push adds elements to an array, and $each allows adding multiple values at once.
Fill both blanks to add the numbers 10, 20, and 30 to the scores array only if they are not already present.
db.players.updateOne({ name: 'Bob' }, { [1]: { scores: { [2]: [10, 20, 30] } } })$addToSet adds unique values to an array, and $each allows adding multiple values at once.