Database
db={"mails":[{subject:"ABC",body:"this is message",recipients:[{userId:1,stutus:"pending"},{userId:2,stutus:"pending"}],sender:2}],"users":[{"_id":1,"firstName":"A","lastName":"A"},{"_id":2,"firstName":"B","lastName":"B"},]}
Query
db.mails.aggregate([{$unwind:"$recipients"},{$lookup:{from:"users",localField:"recipients.userId",foreignField:"_id",as:"recipients.userId"}},{$unwind:"$recipients.userId"},{$lookup:{from:"users",localField:"sender",foreignField:"_id",as:"sender"}},{$unwind:"$sender"},{$group:{_id:"$_id",recipients:{$push:"$recipients"},subject:{$first:"$subject"},body:{$first:"$body"},sender:{$first:"$sender"}}}])