ใช้ $set สำหรับอัปเดตฟิลด์ซ้อนกัน
เพื่ออัปเดตฟิลด์ภายในออบเจกต์ซ้อน (nested object) ให้ใช้ตัวดำเนินการ $set พร้อม dot notation
ตัวอย่าง
> db.updateChildObjectsDemo.insertOne({"StudentName":"Chris","StudentOtherDetails":{"StudentSubject":"MongoDB","StudentCountryName":"AUS"}});
คำสั่งอัปเดต StudentCountryName จาก AUS เป็น UK:
> db.updateChildObjectsDemo.update({"StudentName": "Chris"}, {$set: {"StudentOtherDetails.StudentCountryName": "UK"}});
ผลลัพธ์: ฟิลด์ StudentCountryName เปลี่ยนเป็น UK