Skip to content

Create dump/1 for saving filters #42

@rcdilorenzo

Description

@rcdilorenzo

A particular type of JSON format must be followed to construct a filter. However, no method currently exists to dump a filter to a JSON-encodable format that can be later re-serialized into a filter. The following should work:

import Filtrex.Type.Config
config = defconfig do
  text :title
end

{:ok, filter} = Filtrex.parse_params(config, %{"title_contains" => "Buy"})
assert Filtrex.dump(filter) == %{
  "filter" => %{
    "type" => "all",
    "conditions" => [
      %{"column" => "title", "comparator" => "contains",
        "value" => "Buy", "type" => "text"}
    ],
  "sub_filters" => []
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions