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

Parse Phoenix-like Params Into Filter Query #4

Closed
rcdilorenzo opened this issue Feb 22, 2016 · 0 comments
Closed

Parse Phoenix-like Params Into Filter Query #4

rcdilorenzo opened this issue Feb 22, 2016 · 0 comments

Comments

@rcdilorenzo
Copy link
Owner

Currently, it is required to have a complete data structure in order to construct a query from a client. However, this is impractical when trying to do a GET request with filter type parameters. Using the validation and existing features of the library, it would be very helpful to be able to parse parameters such as the following:

/endpoint?completed_date_at_or_after=2016-03-10&title_contains=blah&status=completed

into something like

%Filtrex{type: "all", conditions: [
  %Filtrex.Condition.Date{column: "completed_date", comparator: "at or after", value: "2016-03-10"},
  %Filtrex.Condition.Text{column: "status", comparator: "equals", value: "completed"},
  %Filtrex.Condition.Text{column: "title", comparator: "contains", value: "blah"}
]}

This parsing would allow use of the complex ecto queries from url parameters and yet allow for customizability.

The additional verbiage of "or_after" or "contains" would be parsed specifically by the condition type and would still have the whitelist configuration for allowed keys on the model that the existing parse call has.

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

1 participant