def to_mongo(self):
        """Translate projection to MongoDB query form.

        :return: Dictionary to put into a MongoDB JSON query
        :rtype: dict
        """
        d = copy.copy(self._fields)
        for k, v in self._slices.items():
            d[k] = {'$slice': v}
        return d
def to_mongo ( self ) : d = copy . copy ( self . _fields ) for k , v in self . _slices . items ( ) : d [ k ] = { '$slice' : v } return d
Translate projection to MongoDB query form.

        :return: Dictionary to put into a MongoDB JSON query
        :rtype: dict