View Source Teiserver.Game.MatchSettingLib (Teiserver v0.0.4)

TODO: Library of match_setting related functions.

Summary

Functions

Returns an %Ecto.Changeset{} for tracking match_setting changes.

Creates many match_settings. Not unlike most other create functions this will raise an exception on failure and should not be caught using the normal case functions.

Creates a match_setting.

Deletes a match_setting.

Returns a key => value map of match settings for a given match_id.

Returns the list of match_settings.

Functions

Link to this function

change_match_setting(match_setting, attrs \\ %{})

View Source
@spec change_match_setting(Teiserver.Game.MatchSetting.t(), map()) ::
  Ecto.Changeset.t()

Returns an %Ecto.Changeset{} for tracking match_setting changes.

Examples

iex> change_match_setting(match_setting)
%Ecto.Changeset{data: %MatchSetting{}}
Link to this function

create_many_match_settings(attr_list)

View Source
@spec create_many_match_settings([map()]) :: {:ok, map()}

Creates many match_settings. Not unlike most other create functions this will raise an exception on failure and should not be caught using the normal case functions.

Expects a map of values which can be turned into valid match settings.

Examples

iex> create_many_match_settings([%{field: value}])
{:ok, %MatchSetting{}}

iex> create_many_match_settings([%{field: bad_value}])
raise Postgrex.Error
Link to this function

create_match_setting(attrs)

View Source
@spec create_match_setting(map()) ::
  {:ok, Teiserver.Game.MatchSetting.t()} | {:error, Ecto.Changeset.t()}

Creates a match_setting.

Examples

iex> create_match_setting(%{field: value})
{:ok, %MatchSetting{}}

iex> create_match_setting(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

delete_match_setting(match_setting)

View Source
@spec delete_match_setting(Teiserver.Game.MatchSetting.t()) ::
  {:ok, Teiserver.Game.MatchSetting.t()} | {:error, Ecto.Changeset.t()}

Deletes a match_setting.

Examples

iex> delete_match_setting(match_setting)
{:ok, %MatchSetting{}}

iex> delete_match_setting(match_setting)
{:error, %Ecto.Changeset{}}
Link to this function

get_match_setting(match_id, setting_type_id, query_args \\ [])

View Source

Gets a single match_setting.

Returns nil if the MatchSetting does not exist.

Examples

iex> get_match_setting(123)
%MatchSetting{}

iex> get_match_setting(456)
nil
Link to this function

get_match_setting!(match_id, setting_type_id, query_args \\ [])

View Source

Gets a single match_setting.

Raises Ecto.NoResultsError if the MatchSetting does not exist.

Examples

iex> get_match_setting!(123)
%MatchSetting{}

iex> get_match_setting!(456)
** (Ecto.NoResultsError)
Link to this function

get_match_settings_map(match_id)

View Source
@spec get_match_settings_map(Teiserver.match_id()) :: %{
  required(String.t()) => String.t()
}

Returns a key => value map of match settings for a given match_id.

Examples

iex> get_match_settings_map(123)
%{"key1" => "value1", "key2" => "value2"}

iex> get_match_settings_map(456)
%{}
Link to this function

list_match_settings(query_args)

View Source
@spec list_match_settings(Teiserver.query_args()) :: [Teiserver.Game.MatchSetting.t()]

Returns the list of match_settings.

Examples

iex> list_match_settings()
[%MatchSetting{}, ...]
Link to this function

update_match_setting(match_setting, attrs)

View Source
@spec update_match_setting(Teiserver.Game.MatchSetting.t(), map()) ::
  {:ok, Teiserver.Game.MatchSetting.t()} | {:error, Ecto.Changeset.t()}

Updates a match_setting.

Examples

iex> update_match_setting(match_setting, %{field: new_value})
{:ok, %MatchSetting{}}

iex> update_match_setting(match_setting, %{field: bad_value})
{:error, %Ecto.Changeset{}}