Current section

Files

Jump to
kura include kura.hrl
Raw

include/kura.hrl

-ifndef(KURA_HRL).
-define(KURA_HRL, true).
-record(kura_field, {
name :: atom(),
type :: kura_types:kura_type(),
column :: binary() | undefined,
default :: term(),
primary_key = false :: boolean(),
nullable = true :: boolean(),
virtual = false :: boolean()
}).
-record(kura_constraint, {
type :: unique | foreign_key | check | exclusion,
constraint :: binary(),
field :: atom(),
message :: binary()
}).
-record(kura_changeset, {
valid = true :: boolean(),
schema :: module() | undefined,
data = #{} :: map(),
params = #{} :: map(),
changes = #{} :: map(),
errors = [] :: [{atom(), binary()}],
types = #{} :: #{atom() => kura_types:kura_type()},
required = [] :: [atom()],
action :: atom() | undefined,
constraints = [] :: [#kura_constraint{}],
assoc_changes = #{} :: #{atom() => #kura_changeset{} | [#kura_changeset{}]},
prepare = [] :: [fun((#kura_changeset{}) -> #kura_changeset{})],
optimistic_lock :: atom() | undefined
}).
-record(kura_assoc, {
name :: atom(),
type :: belongs_to | has_one | has_many | many_to_many,
schema :: module(),
foreign_key :: atom() | undefined,
join_through :: binary() | module() | undefined,
join_keys :: {atom(), atom()} | undefined,
through :: [atom()] | undefined
}).
-record(kura_embed, {
name :: atom(),
type :: embeds_one | embeds_many,
schema :: module()
}).
-record(kura_query, {
from :: atom() | module() | undefined,
select = [] :: [atom() | term()] | {exprs, [term()]},
wheres = [] :: [term()],
joins = [] :: [term()],
order_bys = [] :: [term()],
group_bys = [] :: [atom()],
havings = [] :: [term()],
limit :: non_neg_integer() | undefined,
offset :: non_neg_integer() | undefined,
distinct = false :: boolean() | [atom()],
lock :: binary() | undefined,
prefix :: binary() | undefined,
preloads = [] :: [atom() | {atom(), list()}],
ctes = [] :: [{binary(), #kura_query{}}],
combinations = [] :: [{union | union_all | intersect | except, #kura_query{}}],
include_deleted = false :: boolean()
}).
-record(kura_column, {
name :: atom(),
type :: kura_types:kura_type(),
nullable = true :: boolean(),
default :: term(),
primary_key = false :: boolean(),
references :: {binary(), atom()} | undefined,
on_delete :: cascade | restrict | set_null | no_action | undefined,
on_update :: cascade | restrict | set_null | no_action | undefined
}).
-endif.