kura_types (kura v1.19.2)

View Source

Type system for casting, dumping, and loading values between Erlang and PostgreSQL.

Supported types: id, integer, float, string, text, boolean, date, utc_datetime, uuid, jsonb, {array, Type}.

  • cast/2 — coerce external input to Erlang terms
  • dump/2 — convert Erlang terms to pgo-compatible values
  • load/2 — convert pgo results back to Erlang terms

Summary

Functions

Coerce external input to an Erlang term for the given type.

Convert an Erlang term to a pgo-compatible value for storage.

Convert a pgo result value back to an Erlang term.

Return the PostgreSQL DDL type string for a kura type.

Types

kura_type()

-type kura_type() ::
          id | integer | bigint | smallint | float | decimal | string | text | binary | boolean | date |
          time | utc_datetime | naive_datetime | uuid | jsonb |
          {enum, [atom()]} |
          {array, kura_type()} |
          {embed, embeds_one | embeds_many, module()} |
          {custom, module()}.

Functions

cast/2

-spec cast(kura_type(), term()) -> {ok, term()} | {error, binary()}.

Coerce external input to an Erlang term for the given type.

dump/2

-spec dump(kura_type(), term()) -> {ok, term()} | {error, binary()}.

Convert an Erlang term to a pgo-compatible value for storage.

load/2

-spec load(kura_type(), term()) -> {ok, term()} | {error, binary()}.

Convert a pgo result value back to an Erlang term.

to_pg_type/1

-spec to_pg_type(kura_type()) -> binary().

Return the PostgreSQL DDL type string for a kura type.