PostgrexErlangTerm

Postgrex extension and Ecto type ErlangTerm for use with the PostgreSQL extension pg_erlang_term for sending and storing arbitrary Erlang/Elixir terms efficiently as binaries while still being human-readable in SQL.

Installation

If available in Hex, the package can be installed by adding postgrex_erlang_term to your list of dependencies in mix.exs:

def deps do
  [
    {:postgrex_erlang_term, "~> 0.1.0"}
  ]
end

Add PostgrexErlangTerm.PostgresTypes to your Ecto repo config:

types: PostgrexErlangTerm.PostgresTypes

Usage

In Ecto migrations, use :erlang_term as type on columns like so:

create table(:some_table) do
  add :some_column, :erlang_term
end

On Ecto schemas, use the ErlangTerm type:

alias PostgrexErlangTerm.ErlangTerm

schema "some_table" do
  field :some_column, ErlangTerm
end