Database

db={subject_staff_database:[{"_id":ObjectId("606b7046a0ccf72222c00c2f"),"groupId":ObjectId("5f06cca74e51ba15f5167b86"),"insertedAt":"2021-04-05T20:17:10.144521Z","isActive":true,"staffId":["606b6c34a0ccf72222c5a4df","606b6c48a0ccf722228aa035"],"subjectName":"Maths","teamId":ObjectId("6069a6a9a0ccf704e7f4b537"),"updatedAt":"2022-04-29T07:57:31.072067Z","syllabus":[{"chapterId":"626b9b94ae6cd2092024f3ee","chapterName":"chap1","topicsName":[{"topicId":"626b9b94ae6cd2092024f3ef","topicName":"1.1"},{"topicId":"626b9b94ae6cd2092024f3f0","topicName":"1.2"}]},{"chapterId":"626b9b94ae6cd2092024f3f1","chapterName":"chap2","topicsName":[{"topicId":"626b9b94ae6cd2092024f3f2","topicName":"2.1"},{"topicId":"626b9b94ae6cd2092024f3f3","topicName":"2.2"}]}]}]}

Query

db.subject_staff_database.aggregate([{$match:{"_id":ObjectId("606b7046a0ccf72222c00c2f")}},{$project:{syllabus:{$filter:{input:"$syllabus",as:"item",cond:{$eq:["$$item.chapterId","626b9b94ae6cd2092024f3f1"]}}}}},{$unwind:"$syllabus"},{$project:{"syllabus.topicsName":{$filter:{input:"$syllabus.topicsName",as:"item",cond:{$eq:["$$item.topicId","626b9b94ae6cd2092024f3f2"]}}},"syllabus.chapterId":1,"syllabus.chapterName":1,_id:0}}])

Result