Is it possible to achieve the following with the aggregation pipeline?

Hello, I’m sharing a question I asked on stackoverflow but have not received any answer yet: https://stackoverflow.com/questions/67106698/is-there-a-more-efficient-way-to-query-a-mongodb-collection-and-normalize-the-re

As you can see, I’m using pymongo to connect to MongoDB, query the database then use pandas’ json_normalize - but that is quite memory heavy. Could you let me know if there is either a more efficient way to query the db or if there is an alternative way? Is the above possible with the aggregation pipeline?

Thanks!