Database
[{"_id":ObjectId("5df58d45244a850d54b922c8"),"mentors":{"numOfMentors":NumberInt(1),"mentorList":[ObjectId("5c9ba636347bb645e0865283")]},"lessons":[{"_id":ObjectId("5db221be211d7b68ac8be618"),"mentorData":{"objective":"Ensuring students that making mistakes is normal and that it is a part of life","task":"Post a video explaining obstacles that you had to overcome as a programmer","dueDate":ISODate("2019-12-14T15:26:10.000Z")},"studentData":{"objective":"Learning that failures help you grow","task":"Post a video explaining obstacles that you have overcame","dueDate":ISODate("2020-01-14T22:26:10.000Z")},"title":"How to overcome obstacles","comments":[]}]}]
Query
db.collection.aggregate([{$unwind:"$lessons"},{$addFields:{date:{$dateToString:{format:"%Y-%m-%d",date:"$lessons.studentData.dueDate"}}}},{$group:{_id:"$_id",lessons:{$push:"$lessons"},mentors:{$push:"$mentors.mentorList"}}},{$addFields:{mentors:{$reduce:{input:"$mentors",initialValue:[],in:{$setUnion:["$$value","$$this"]}}}}}])