Filtrex v0.1.0 Filtrex

Filtrex consists of three primary components:

  • Filtrex - handles the overall parsing of filters and delegates to Filtrex.AST to build an ecto query expression

  • Filtrex.Condition - an abstract module built to delegate to specific condition modules in the format of Filtrex.Condition.Type where the type is converted to CamelCase (See Filtrex.Condition.Text.parse/2)

  • Filtrex.Fragment - simple struct to hold generated expressions and values to be used when generating queries for ecto

Summary

Functions

Parses a filter expression and returns errors or the parsed filter with the appropriate parsed sub-structures

Converts a filter with the specified ecto module name into a valid ecto query expression that is compiled when called

Types

Functions

parse(config, arg2)

Specs

parse(Map.t, Map.t) ::
  {:errors, List.t} |
  {:ok, Filtrex.t}

Parses a filter expression and returns errors or the parsed filter with the appropriate parsed sub-structures.

The config option is a map of the acceptable types and the configuration options to pass to each condition type. Example:

%{
  text: %{keys: ~w(title comments)}
}
query(filter, model, env)

Specs

query(Filter.t, module, Macro.Env.t) :: Ecto.Query.t

Converts a filter with the specified ecto module name into a valid ecto query expression that is compiled when called.