Database
db={"Documents":[{"_id":ObjectId("5eb256c9e519051af2eeb5f7"),"name":"Income","types":[{"typeId":ObjectId("5eb257a3e519051af2eeb624"),"name":"W2","tenantId":null,"message":"","createdOn":null,"createdBy":1.0,"isActive":true},{"typeId":ObjectId("5eb257a3e519051af2eeb639"),"name":"Salary Slip","tenantId":1,"message":"","createdOn":null,"createdBy":1.0,"isActive":true}]}],"Requests":[{"_id":ObjectId("5eb25d1fe519051af2eeb72d"),"employeeId":1234,"customerId":1275,"tenantId":1,"createdOn":ISODate("2013-10-01T00:00:00.000Z"),"loanApplicationId":1.0,"status":"requested","message":"Dear John, please send following documents.","documents":[{"typeId":null,"displayName":"W2 2016","message":"please upload salary slip for year 2016","status":"requested","files":[]},{"typeId":ObjectId("5eb257a3e519051af2eeb624"),"displayName":"W2 2016","message":"please upload salary slip for year 2016","status":"requested","files":[]}]}]}
Query
db.Requests.aggregate([{$lookup:{from:"Documents",localField:"documents.typeId",foreignField:"types.typeId",as:"tmp"}},{$addFields:{tmp:"$$REMOVE",documents:{$map:{input:"$documents",as:"doc",in:{$mergeObjects:["$$doc",{$reduce:{input:{$reduce:{input:"$tmp.types",initialValue:[],in:{$concatArrays:["$$value","$$this"]}}},initialValue:{},in:{$cond:[{$eq:["$$this.typeId","$$doc.typeId"]},{typeInfo:{name:"$$this.name"}},"$$value"]}}}]}}}}}])