Ash FrameworkAF
Ash Framework3y ago
66 replies
ZachDaniel

Issues with sorting on `first` aggregate

actions do
  defaults [:create, :read, :update, :destroy]

  read :published do
    prepare fn query, _context ->
      query
      |> Ash.Query.filter(air_dates.status == :published)
      |> Ash.Query.sort(latest_air_date: :desc)
      |> Ash.Query.limit(10)
    end

    # pagination do
    #   offset? true
    #   default_limit 10
    #   countable :by_default
    # end
  end
end
...
preparations do
  prepare fn query, _context ->
    query
    |> Ash.Query.load([:thumb_url, :video_file_url, :video_poster_url])
  end
end

aggregates do
  first :latest_air_date, :air_dates, :start do
    sort start: :desc
  end
end


Originally posted by @l00ker , moved to a support thread
Was this page helpful?