Database

[{"cityName":"New York","factories":[{"factoryName":"factory1","productAmount":400,"numberOfWorkers":5,"workersProductionPerSecond":0.1},{"factoryName":"factory2","productAmount":200,"numberOfWorkers":3,"workersProductionPerSecond":0.2}]},{"cityName":"New Jersey","factories":[{"factoryName":"New factory","productAmount":100,"numberOfWorkers":5,"workersProductionPerSecond":0.25},{"factoryName":"New Factory 2","productAmount":200,"numberOfWorkers":5,"workersProductionPerSecond":0.4}]}]

Query

db.collection.update({},[{$set:{factories:{$map:{input:"$factories",as:"item",in:{factoryName:"$$item.factoryName",productAmount:{$add:[{$multiply:["$$item.numberOfWorkers","$$item.workersProductionPerSecond"]},"$$item.productAmount"]},numberOfWorkers:"$$item.numberOfWorkers",workersProductionPerSecond:"$$item.workersProductionPerSecond"}}}}}],{multi:true})

Result