Caravela.Types (Caravela v0.9.2)

Copy Markdown View Source

Type mapping between the Caravela DSL, Ecto, and Postgres.

The DSL uses plain atoms like :string, :integer, :decimal, :text. Those are translated into Ecto field types (for schema generation) and Postgres column types (for migration generation).

Summary

Types

A DSL type atom recognised by Caravela.

Functions

Ecto type for a DSL atom. Raises if unknown.

Is the atom a known DSL type?

All DSL types recognised by Caravela.

True for numeric DSL types.

Postgres column type for a DSL atom. Raises if unknown.

True for string-ish DSL types.

Types

dsl_type()

@type dsl_type() :: atom()

A DSL type atom recognised by Caravela.

Functions

ecto_type(type)

@spec ecto_type(dsl_type()) :: atom()

Ecto type for a DSL atom. Raises if unknown.

known?(type)

@spec known?(dsl_type()) :: boolean()

Is the atom a known DSL type?

known_types()

@spec known_types() :: [dsl_type()]

All DSL types recognised by Caravela.

numeric?(type)

@spec numeric?(dsl_type()) :: boolean()

True for numeric DSL types.

postgres_type(type)

@spec postgres_type(dsl_type()) :: atom()

Postgres column type for a DSL atom. Raises if unknown.

string_like?(type)

@spec string_like?(dsl_type()) :: boolean()

True for string-ish DSL types.