How does mongodb aggregate the List type fields of each document and return them as a whole?

  mongodb, question

For example, mongodb database, ORM model established by mongoengine, an existing entity has a List type field, such as:

class Service(Document):
 xx = ListField(StringFiled(...))

Now I want to summarize the list of xx fields recorded in each Service document into a list. how is it reasonable to write it?
There is a better grammar for mongoengine. It is ok not to tell me pymongo. Please give me an idea. Thank you!

The Aggregation Framework (2.2 after version 2.2) can easily solve this problem.

In$groupIn operation,$pushOr ..$addToSetCan meet your needs. Driver such as pymongo also support the Aggregation Framework.