Here i will Query you how to update the details in the mongo DB. and find out my initial data in the Mongo DB below.


{ "Student_name" : "Raja", "Department" : "Computer Science and Engg", "Marks" : [69, 78, 88,95]  }

{ "Student_name" : "Rahul", "Department" : "Computer Science and Engg", "Marks" : [59, 74, 80]  }

{ "Student_name" : " Bittu ", "Department" : "Computer Science and Engg", "Marks" : [99, 95, 84,69]  }

{ "Student_name" : "Siva", "Department" : "ECE", "Marks" : [ 56, 89, 56, 78 ],
    "Activities" : {
        "Sports" : "Cricket",
        "Studies" : "Avg",
        "others" : "Coin Collection"
    }  }



Updating the record with the name ‘Bittu’ changing the Department name and Marks

db.studentDetails.update
(
    {Student_name:'Bittu'},
    {
     $set:{
         Department:'CSE',
         Marks:[98,99,87,85]
          }
    }
)
After updating your record of Student_name: ‘ bittu ‘looks like as below,
{ “Student_name" : "Bittu", "Department" : "CSE",    "Marks" : [ 98,99,87,85 ] }


Updating the Embedded data can compute with Dot Notation in the single Quotes as Shown below


db.studentDetails.update
(
    {  Student_name:'Siva'},
    {
        $set:
        {
            'Activities.Studies':'Good'
        }
    }
)

From the above Query we have updated the Activities and Studies as Good, for the Student_name ‘siva’, After Successful updating, your Data looks as below.


{ "Student_name" : "Siva", "Department" : "ECE", "Marks" : [ 56, 89, 56, 78 ],
        "Activities" : {
          "Sports" : "Cricket",
"Studies" : "Good",
"others" : "Coin Collection"
    }

}