pagantis_elixir_tools v0.15.0 ElixirTools.Events.NotSentEvent

Schema used for saving not sent (due to a failure) events to DB. They supposed to be resend later, after this a field is_sent has to be set to true

Link to this section Summary

Functions

Fetches all records from the DB.

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.

Gets the last record (by inserted_at) where given field equals given value. Returns nil if nothing was found.

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 or multiple fields on a struct.

Returns the default repo

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 type

external_reference()

external_reference() :: String.t()
Link to this type

t()

t() :: %ElixirTools.Events.NotSentEvent{
  __meta__: term(),
  content: String.t(),
  id: id() | nil,
  inserted_at: term(),
  is_sent: boolean(),
  updated_at: term()
}

Link to this section Functions

Link to this function

all(queryable \\ [])

all(list()) :: [t()]

Fetches all records from the DB.

Link to this function

create(map \\ %{})

create(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!(map \\ %{})

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

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

Link to this function

get_by(queryable)

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

Gets the first record by key: value

Link to this function

get_by!(queryable)

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

Gets the first record by key: value

Link to this function

insert(struct)

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

Inserts a struct into the database.

Link to this function

insert!(struct)

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

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

Link to this function

last(field, value)

last(atom(), any()) :: t() | nil

Gets the last record (by inserted_at) where given field equals given value. Returns nil if nothing was found.

Link to this function

new(map \\ %{})

new(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(struct, field, opts \\ [])

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

Preloads a field or multiple fields on a struct.

Link to this function

repo()

repo() :: module()

Returns the default repo

Link to this function

update(struct, map)

update(t(), changes :: 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!(struct, map)

update!(t(), changes :: map()) :: t() | no_return()

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

Link to this function

validate(map_or_struct)

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

Validates a map or struct.