EpochtalkServer.Models.Configuration (epochtalk_server v0.1.0)

Configuration model, for performing actions relating to frontend Configuration

Link to this section Summary

Functions

Gets a Configuration from the database by name

Creates a new Configuration into the database

Create changeset for creating a new Configuration model

Gets default frontend Configuration from the database

Inserts a default Configuration into the database given config_map

Warms :epochtalk_server[:frontend_config] config variable using Configuration stored in database, if present. If there is no Configuration in the database, the default value is taken from :epochtalk_server[:frontend_config] and inserted into the database as the default Configuration. Run as a Task on application startup.

Link to this section Types

@type t() :: %EpochtalkServer.Models.Configuration{
  __meta__: term(),
  config: map() | nil,
  id: non_neg_integer() | nil,
  name: String.t() | nil
}

Link to this section Functions

@spec by_name(name :: String.t()) :: t() | nil

Gets a Configuration from the database by name

Link to this function

create(configuration)

@spec create(configuration :: t()) ::
  {:ok, configuration :: t()} | {:error, Ecto.Changeset.t()}

Creates a new Configuration into the database

Link to this function

create_changeset(configuration, attrs \\ %{})

@spec create_changeset(
  configuration :: t(),
  attrs :: map() | nil
) :: Ecto.Changeset.t()

Create changeset for creating a new Configuration model

@spec get_default() :: t() | nil

Gets default frontend Configuration from the database

Link to this function

set_default(config_map)

@spec set_default(config_map :: map()) ::
  {:ok, configuration :: t()} | {:error, Ecto.Changeset.t()}

Inserts a default Configuration into the database given config_map

Link to this function

warm_frontend_config()

@spec warm_frontend_config() :: :ok

Warms :epochtalk_server[:frontend_config] config variable using Configuration stored in database, if present. If there is no Configuration in the database, the default value is taken from :epochtalk_server[:frontend_config] and inserted into the database as the default Configuration. Run as a Task on application startup.