ion}')`
          : `_.sortBy(${query}, '${sort.direction}')`
      }

      if (projection) {
        // It is possible to make a util function "pickFlat"
        // and use that when building the query to make it more readable.
        if (projection.fields.length > 1) {
          const fields = projection.fields.map(field => {
            const name = _.last(field.split('.'))
            return `  '${name}': _.get(item, '${field}')`
          })
          query = `_.map(${query}, item => ({\n${fields.joi