pagantis_elixir_tools v0.21.3 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
Specs
t() :: struct()
Link to this section Functions
all(module, queryable)
Specs
all(ecto_schema(), Ecto.Query.t() | module()) :: [t()]
Gets all entities based on query. If no query is given, all entities are returned.
create(module, map \\ %{})
Specs
Creates a new MODULE struct by parameters and inserts it in the database when the values are valid
create!(module, map \\ %{})
Specs
The same as create/1 but raises an error when validation fails.
get(module, id)
Specs
get(ecto_schema(), ElixirTools.Schema.id()) :: t() | nil
Gets a struct from the database by providing the ID
get!(module, id)
Specs
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
get_by(module, queryable)
Specs
Gets the first record by key
: value
get_by!(module, queryable)
Specs
Gets the first record by key
: value
insert(module, struct)
Specs
Inserts a struct into the database.
insert!(module, struct)
Specs
Inserts a struct in the database and throws an error when it fails.
last(module, field, value)
Specs
new(module, map \\ %{})
Specs
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.
preload(repo, struct, field, opts \\ [])
Specs
Preloads a field on a struct.
update(module, struct, map)
Specs
Alters the struct with the values and updates the database record. The first argument takes the original struct, the second a map with changes.
update!(module, struct, map)
Specs
The same as update/2
but raises an error when validation fails.
validate(module, struct)
Specs
validate(ecto_schema(), map() | t()) :: {:ok, Ecto.Changeset.t()} | {:error, [{}]}
Validates a map or struct.