Updating single element in Array data type in mongodb using shell

I have an 2 documents in mongodb like below

now I want to update grades value of 100 to 1000 below is the Query for updating single element in Array.

in above Query  dummy_collection is the Collection name and it will replace 100 to 1000  from all documents in Collection

if we want to Update element in nested array

Now i want to update the 75 in grade array below will be the query

In above Query by using dotted Notation  we are mentioning the MongoDB to update the array which is under allGrades where grade array value is 75 to 80

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *