Filtrex v0.4.0 API Reference

Modules

Filtrex consists of the following primary components

Filtrex.AST is a helper for building out the ecto macro query expression from a set of conditions. Typically, it shouldn’t need to be called direcly

Filtrex.Condition is an abstract module for parsing conditions. To implement your own condition, add use Filtrex.Condition in your module and implement the three callbacks

Filtrex.Condition.Boolean is a specific ondition type for handling boolean flags. It allows an empty string for false value as well as string representations “true” and “false”. Its comparators only consist of “equals” or “does not equal”. There are no configuration options for the boolean condition

Filtrex.Condition.Date is a specific condition type for handling date filters with various comparisons

Filtrex.Condition.DateTime is a specific condition type for handling datetime filters with various comparisons

Filtrex.Condition.Number is a specific condition type for handling integer and decimal filters with various configuration options

Filtrex.Condition.Text is a specific condition type for handling text filters with various comparisons. There are no configuration options for the date condition

Filtrex.Fragment is a simple struct used to hold an expression and values. It is used by Filtrex.Encoder.encode/1 to turn conditions into ecto queries. Example:

%Filtrex.Fragment{expression: "(text = ?)", values: ["Buy Milk"]}

Filtrex.Params is a module that parses parameters similar to Phoenix, such as

This configuration struct is for passing options at the top-level (e.g. Filtrex.parse/2) in a list. See defconfig/1 for a more specific example

Helper methods for implementing the Filtrex.Encoder protocol

Protocols

Encodes a condition into Filtrex.Fragment as an expression with values. Implementing this protocol is required for any new conditions. See Filtrex.Utils.Encoder for helper methods with this implementation