Ash FrameworkAF
Ash Framework6mo ago
7 replies
Joan Gavelán

Working with AshArchival

I'd like to to implement a filter that allows the user to read their archived records. I'm trying this:
Ash.Query.filter_input(query, %{"archived_at" => %{"is_nil" => false}})

But for some reason I get no results

I tried the exclude_read_actions option

archive do
  attribute :archived_at
  exclude_read_actions :list_contacts
end


But still get no results for my action

action :list_contacts, :map do
  argument :search, :string
  argument :filter, :map
  argument :sort, :string
  argument :page, :string, default: "1"

  run {MyApp.Actions.Listing,
       resource: __MODULE__, search_by: [:name], serializer: :serialize_contacts}
end


I do get the results when I try to read unarchived records though

Note: I'm not using the base_filter
Solution
So if you make like an :include_archived action for example, exclude that action in the ash archival DSL, you can then pass action: :include_archived to Ash.read
Was this page helpful?