Database
[{"CurrentVersion":3,"EntryHistory":[{"State":0,"ProposalPlan":[{"Description":"Test","State":1,"Proposals":[{"Subject":"Test","Body":"Test","Urls":[{"Description":"Link text","Address":"https://examplelink0.com"},{"Description":"Link text","Address":"https://examplelink1.com"},{"Description":"Link text","Address":"https://examplelink2.com"},{"Description":"Link text","Address":"https://examplelink3.com"},{"Description":"Link text","Address":"https://examplelink4.com"}]},{"Subject":"Test","Body":"Test","Urls":[{"Description":"Link text","Address":"https://proposals0.com"},{"Description":"Link text","Address":"https://proposals11.com"}]}]}]}]}]
Query
db.collection.update({},[{$set:{"EntryHistory":{"$map":{"input":"$EntryHistory","as":"e","in":{"$mergeObjects":["$$e",{"ProposalPlan":{"$map":{"input":"$$e.ProposalPlan","as":"p","in":{"$mergeObjects":["$$p",{"$cond":{"if":{"$eq":["$$p.State",1]},"then":{State:3,Proposals:{"$map":{"input":"$$p.Proposals","as":"r","in":{"$mergeObjects":["$$r",{"$cond":{"if":{"$eq":[{"$indexOfArray":["$$p.Proposals","$$r"]},0/** Index of Proposals*/]},"then":{"Urls":{"$map":{"input":"$$r.Urls","as":"u","in":{"$mergeObjects":["$$u",{"$cond":{"if":{"$eq":[{"$indexOfArray":["$$r.Urls","$$u"]},2/** Index of Urls*/]},"then":{Address:"Example new link"},"else":{}}}]}}}},"else":{}}}]}}}},"else":{}}}]}}}}]}}}}}])