Filtrex.Encoder protocol (Filtrex v0.5.0)

Copy Markdown View Source

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.

Example:

defimpl Filtrex.Encoder, for: Filtrex.Condition.Text do
  def encode(%Filtrex.Condition.Text{column: column, comparator: "equals", value: value}) do
    %Filtrex.Fragment{expression: "#{column} = ?", values: [value]}
  end
end

Summary

Types

t()

All the types that implement this protocol.

Functions

The function that performs the encoding

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

encode(condition)

@spec encode(Filter.Condition.t()) :: [String.t() | [any()]]

The function that performs the encoding