I have to insert an object in every array in the MongoDB document. The items array displayed below has itemList; in every itemList I have to insert a itemSpec. The desired document shape before and after the process is shown below:
Before process
{
"items": [
{
"itemList":{
"rejected": true
},
"fProcBy": "automatic"
},
{
"itemList":{
"rejected": true
},
"fProcBy": "automatic"
}
]
}
After process:
{
"items": [
{
"itemList":{
"rejected": true
},
"itemSpec":{
"approved": true
},
"fProcBy": "automatic"
},
{
"itemList":{
"rejected": true
},
"itemSpec":{
"approved": true
},
"fProcBy": "automatic"
}
]
}
So in each element of the items array there has to be inserted a new object property itemSpec.