I am trying to update(add if not present) a property to each object in array in mongodb document. For example
My document :
{
"_id" : "1",
student : [
{
"name" : "rajesh",
"rollno" : 1
},
{
name" : "rajesh2",
"rollno" : 2
},
{
name" : "rajesh3",
"rollno" : 3,
class : 6
}
]
}
I want to add property 'class' to all the object in student array. How can I do this in mongodb.
classsupposed to have?