Solution: Updating Arrays
We'll cover the following...
Query
db.products.updateMany({ price: { $lte: 0 } },{$set: {price: 49,status: "Inactive"},$addToSet: {tags: "needs-review"}}), db.products.find({status: "Inactive"})
Explanation
The explanation of the query is given below:
Line 1:
db.products.updateMany; this command tells MongoDB to update multiple documents inside the ...