Nearby lessons
7 of 22⚙️ MongoDB: Update and Array Operators
MongoDB provides powerful update operators to modify documents and arrays within a collection.
You can add, remove, rename, or manipulate fields and arrays dynamically.
📚 Initial Data Setup
Example01
1️⃣ Using $push — Add an Element to an Array
Example02
2️⃣ Using $pop — Remove First or Last Element
Example03
3️⃣ Using $pull — Remove a Specific Element
Example04
4️⃣ Using $addToSet — Add Unique Element
Example05
5️⃣ Using $set — Update a Field
Example06
6️⃣ Using $unset — Remove a Field
Example07
7️⃣ Using $rename — Rename a Field
Example08
8️⃣ Using $inc — Increment a Field Value
Example09
9️⃣ Using $mul — Multiply a Field Value
Example10
🔟 Using $currentDate — Add/Update Date Field
Example11
1️⃣1️⃣ Using replaceOne — Replace Entire Document
Example12