pagantis_elixir_tools v0.19.1 ElixirTools.Schema.SchemaImpl

Link to this section Summary

Functions

Gets all entities based on query. If no query is given, all entities are returned.

Creates a new MODULE struct by parameters and inserts it in the database when the values are valid

The same as create/1 but raises an error when validation fails.

Gets a struct from the database by providing the ID

Gets a struct from the database by providing the ID, raises Ecto.NoResultsError if no record was found

Gets the first record by key: value

Gets the first record by key: value

Inserts a struct into the database.

Inserts a struct in the database and throws an error when it fails.

Creates a new changeset by providing map. Returns a struct of the type with the defaults set. Keep in mind that new/1 does not validate.

Preloads a field on a struct.

Alters the struct with the values and updates the database record. The first argument takes the original struct, the second a map with changes.

The same as update/2 but raises an error when validation fails.

Validates a map or struct.

Link to this section Types

Link to this section Functions

Link to this function

all(module, queryable)

all(ecto_schema(), Ecto.Query.t() | module()) :: [t()]

Gets all entities based on query. If no query is given, all entities are returned.

Link to this function

create(module, map \\ %{})

create(ecto_schema(), map()) :: {:ok, t()} | {:error, [{}]}

Creates a new MODULE struct by parameters and inserts it in the database when the values are valid

Link to this function

create!(module, map \\ %{})

create!(ecto_schema(), map()) :: t() | no_return()

The same as create/1 but raises an error when validation fails.

Link to this function

get(module, id)

get(ecto_schema(), ElixirTools.Schema.id()) :: t() | nil

Gets a struct from the database by providing the ID

Link to this function

get!(module, id)

get!(ecto_schema(), ElixirTools.Schema.id()) :: t() | no_return()

Gets a struct from the database by providing the ID, raises Ecto.NoResultsError if no record was found

Link to this function

get_by(module, queryable)

get_by(ecto_schema(), list()) :: t() | nil

Gets the first record by key: value

Link to this function

get_by!(module, queryable)

get_by!(ecto_schema(), list()) :: t() | no_return()

Gets the first record by key: value

Link to this function

insert(module, struct)

insert(ecto_schema(), t()) :: {:ok, t()} | {:error, term()}

Inserts a struct into the database.

Link to this function

insert!(module, struct)

insert!(ecto_schema(), t()) :: t() | no_return()

Inserts a struct in the database and throws an error when it fails.

Link to this function

last(module, field, value)

last(ecto_schema(), atom(), any()) :: t() | nil
Link to this function

new(module, map \\ %{})

new(ecto_schema(), map()) :: t()

Creates a new changeset by providing map. Returns a struct of the type with the defaults set. Keep in mind that new/1 does not validate.

Link to this function

preload(repo, struct, field, opts \\ [])

preload(repo(), t(), field :: atom() | [atom()], list()) :: t()

Preloads a field on a struct.

Link to this function

update(module, struct, map)

update(ecto_schema(), struct(), map()) :: {:ok, t()} | {:error, [{}]}

Alters the struct with the values and updates the database record. The first argument takes the original struct, the second a map with changes.

Link to this function

update!(module, struct, map)

update!(ecto_schema(), struct(), map()) :: t() | no_return()

The same as update/2 but raises an error when validation fails.

Link to this function

validate(module, struct)

validate(ecto_schema(), map() | t()) ::
  {:ok, Ecto.Changeset.t()} | {:error, [{}]}

Validates a map or struct.