Database
db={"professionalSchema":[{"_id":ObjectId("6009a0d0874f0900086ee0ce"),"firstName":"xxxx","gender":"NOT_SPECIFIED","contractType":[{"authorizedBy":ObjectId("5fad90665d963cbbbd4a6580"),"document":"document 1"},{"authorizedBy":ObjectId("5fad90665d963cbbbd4a6580"),"document":"document 2"}]}],"adminSchema":[{"_id":ObjectId("5fad90665d963cbbbd4a6580"),"role":"SAM","firstName":"firstname","lastName":"lastname"}]}
Query
db.professionalSchema.aggregate([{"$match":{"_id":ObjectId("6009a0d0874f0900086ee0ce")}},{"$unwind":{"path":"$contractType"}},{"$lookup":{"from":"adminSchema","localField":"contractType.authorizedBy","foreignField":"_id","as":"contractType.authorizedBy"}},{"$addFields":{"contractType.authorizedBy":{$ifNull:[{$arrayElemAt:["$contractType.authorizedBy",0]},""]}}},{"$group":{"_id":"$_id","firstName":{$first:"$firstName"},"gender":{$first:"$gender"},contractType:{$push:"$contractType"}}}])