Database
db={"Story":[{"id":"s1"}],"Chapter":[{"id":"ch1","story_id":"s1"},{"id":"ch2","story_id":"s1"}],"Comment":[{"id":"C1","chapter_id":"ch1"},{"id":"C2","chapter_id":"ch2"}]}
Query
db.Story.aggregate([{"$lookup":{"from":"Chapter","localField":"id","foreignField":"story_id","as":"chapter"}},{"$unwind":"$chapter"},{"$lookup":{"from":"Comment","localField":"chapter.id","foreignField":"chapter_id","as":"comment"}},{"$unwind":"$comment"},{"$group":{"_id":"$id","count":{"$sum":1}}}])