def add_fields(self, **fields):
        """
        Adds a stage to aggregation query which adds new fields to documents.
        :param fields: The fields that will be created
        :return: The current object
        """
        query = {}
        for field in fields:
            query[field] = fields[field]
        self._q.append({'$addFields': query})
        return self
def add_fields ( self , ** fields ) : query = { } for field in fields : query [ field ] = fields [ field ] self . _q . append ( { '$addFields' : query } ) return self
Adds a stage to aggregation query which adds new fields to documents.
        :param fields: The fields that will be created
        :return: The current object