Shrine

Help with Sequel query using SQLite3

I have the following Category model in my Roda app using Sequel with SQLite3 and I’m trying to return specific fields along with the thumb derivative of the attached image in an API response. Is there an easier method to pluck out the thumb derivative inside the api_query function instead of having to transform the returned data as per below?

class Category < Sequel::Model
  include ImageUploader::Attachment(:image)

  dataset_module do
    def api_query
      select(:id, :name, :slug, :image_data).
      where(enabled: true).
      order(:name).
      all
    end

    def transform_for_api
      results = []
      api.each do |res|
        results.push({
          id: res.id,
          name: res.name,
          slug: "/categories/#{res.slug}",
          images: res.image_data.present? ?
            { thumb: res.image_url(:thumb) } :
            { }
        })
      end
      results
    end
end