View Source Electric.Replication.Eval.Runner (electric v0.9.5)

Summary

Functions

Run a PG function parsed by Electric.Replication.Eval.Parser based on the inputs

Generate a ref values object based on the record and a given table name

Functions

Link to this function

execute(tree, ref_values)

View Source
@spec execute(Electric.Replication.Eval.Expr.t(), map()) ::
  {:ok, term()}
  | {:error,
     {%Electric.Replication.Eval.Parser.Func{
        args: term(),
        immutable?: term(),
        implementation: term(),
        location: term(),
        map_over_array_in_pos: term(),
        name: term(),
        strict?: term(),
        type: term(),
        variadic_arg: term()
      }, [term()]}}

Run a PG function parsed by Electric.Replication.Eval.Parser based on the inputs

Link to this function

record_to_ref_values(used_refs, record, env \\ Env.new())

View Source
@spec record_to_ref_values(
  Electric.Replication.Eval.Expr.used_refs(),
  map(),
  Electric.Replication.Eval.Env.t()
) :: {:ok, map()} | :error

Generate a ref values object based on the record and a given table name

Examples

iex> used_refs = %{["id"] => :int8, ["created_at"] => :timestamp}
iex> record_to_ref_values(used_refs, %{"id" => "80", "created_at" => "2020-01-01T11:00:00Z"})
%{
  ["id"] => 80,
  ["created_at"] => ~N[2020-01-01 11:00:00]
}