Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create dump/1 for saving filters #42

Open
rcdilorenzo opened this issue Aug 16, 2017 · 3 comments
Open

Create dump/1 for saving filters #42

rcdilorenzo opened this issue Aug 16, 2017 · 3 comments

Comments

@rcdilorenzo
Copy link
Owner

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" => []
}
@rcdilorenzo

This comment has been minimized.

@rcdilorenzo rcdilorenzo modified the milestones: 0.4.0, 0.5.0 Aug 16, 2017
@rcdilorenzo rcdilorenzo removed this from the 0.5.0 milestone Sep 16, 2017
@gen1321
Copy link

gen1321 commented Nov 8, 2018

I Want to make a pr for this one. I hope you don't mind :)

@rcdilorenzo
Copy link
Owner Author

Go for it @gen1321! I certainly don't mind. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants