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.
Gets a single match_setting.
Gets a single match_setting.
Returns a key => value map of match settings for a given match_id.
Returns the list of match_settings.
Updates a match_setting.
Functions
@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{}}
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
@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{}}
@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{}}
@spec get_match_setting( Teiserver.match_id(), Teiserver.Game.MatchSettingType.id(), Teiserver.query_args() ) :: Teiserver.Game.MatchSetting.t() | nil
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
@spec get_match_setting!( Teiserver.match_id(), Teiserver.Game.MatchSettingType.id(), Teiserver.query_args() ) :: Teiserver.Game.MatchSetting.t()
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)
@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)
%{}
@spec list_match_settings(Teiserver.query_args()) :: [Teiserver.Game.MatchSetting.t()]
Returns the list of match_settings.
Examples
iex> list_match_settings()
[%MatchSetting{}, ...]
@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{}}