LazyContext v0.1.4-dev LazyContext.Examples.Users View Source

An example context to demonstrate basic use of the LazyContext library

Link to this section Summary

Functions

Returns a data structure for tracking %Elixir.LazyContext.Examples.Users.Schemas.User{} changes

Updates a %Elixir.LazyContext.Examples.Users.Schemas.User{} if it already exists, otherwise creates one

Updates a %Elixir.LazyContext.Examples.Users.Schemas.User{} if it already exists, otherwise creates one

Creates an “empty” %Elixir.LazyContext.Examples.Users.Schemas.User{}, if valid. Equivalent to calling create_user(%{})

Creates a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Creates an “empty” %Elixir.LazyContext.Examples.Users.Schemas.User{}, if valid. Equivalent to calling create_user!(%{})

Creates a %Elixir.LazyContext.Examples.Users.Schemas.User{}

deletes a %Elixir.LazyContext.Examples.Users.Schemas.User{}

deletes a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Gets a single %Elixir.LazyContext.Examples.Users.Schemas.User{} where the primary key matches the given ID, with [] preloaded

Gets a single %Elixir.LazyContext.Examples.Users.Schemas.User{} where the primary key matches the given ID, with [] preloaded

Returns a list of %Elixir.LazyContext.Examples.Users.Schemas.User{} with [] preloaded

Updates a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Updates a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Link to this section Types

Link to this type user() View Source
user() :: %LazyContext.Examples.Users.Schemas.User{
  __meta__: term(),
  age: term(),
  cats: term(),
  dogs: term(),
  email: term(),
  ferrets: term(),
  first_name: term(),
  id: term(),
  last_name: term()
}

Link to this section Functions

Link to this function change_user(item, attrs \\ %{}) View Source
change_user(user(), map()) :: Ecto.Changeset.t()

Returns a data structure for tracking %Elixir.LazyContext.Examples.Users.Schemas.User{} changes.

Examples

iex> change_user(%Elixir.LazyContext.Examples.Users.Schemas.User{}, %{field: value})
%Ecto.Changeset{}

generated via the LazyContext.__using__/1 macro.

Link to this function create_or_update_user(attrs) View Source
create_or_update_user(map()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}

Updates a %Elixir.LazyContext.Examples.Users.Schemas.User{} if it already exists, otherwise creates one.

Whether a %Elixir.LazyContext.Examples.Users.Schemas.User{} already exists is determined by a lookup on the following fields: [:id]

Examples

iex> create_or_updateuser(%{field: value})
{:ok, %Elixir.LazyContext.Examples.Users.Schemas.User{}}
iex> create_user(%{field: bad_value})
{:error, %Ecto.Changeset{}}

generated via the LazyContext.__using__/1 macro.

Link to this function create_or_update_user!(attrs) View Source
create_or_update_user!(map()) :: user() | no_return()

Updates a %Elixir.LazyContext.Examples.Users.Schemas.User{} if it already exists, otherwise creates one.

Whether a %Elixir.LazyContext.Examples.Users.Schemas.User{} already exists is determined by a lookup on the following fields: [:id]

Raises if the changeset is invalid

Examples

iex> create_or_updateuser!(%{field: value})
%Elixir.LazyContext.Examples.Users.Schemas.User{}

generated via the LazyContext.__using__/1 macro.

Link to this function create_user() View Source
create_user() :: {:ok, user()} | {:error, Ecto.Changeset.t()}

Creates an “empty” %Elixir.LazyContext.Examples.Users.Schemas.User{}, if valid. Equivalent to calling create_user(%{})

Examples

iex> create_user()
{:ok, %Elixir.LazyContext.Examples.Users.Schemas.User{}}

generated via the LazyContext.__using__/1 macro.

Link to this function create_user(attrs) View Source
create_user(map()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}

Creates a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Examples

iex> create_user(%{field: value})
{:ok, %Elixir.LazyContext.Examples.Users.Schemas.User{}}
iex> create_user(%{field: bad_value})
{:error, %Ecto.Changeset{}}

generated via the LazyContext.__using__/1 macro.

Link to this function create_user!() View Source
create_user!() :: user() | no_return()

Creates an “empty” %Elixir.LazyContext.Examples.Users.Schemas.User{}, if valid. Equivalent to calling create_user!(%{})

Raises if the changeset is invalid.

Examples

iex> create_user!()
%Elixir.LazyContext.Examples.Users.Schemas.User{}

generated via the LazyContext.__using__/1 macro.

Link to this function create_user!(attrs) View Source
create_user!(map()) :: user() | no_return()

Creates a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Raises if the changeset is invalid.

Examples

iex> create_user!(%{field: value})
%Elixir.LazyContext.Examples.Users.Schemas.User{}

generated via the LazyContext.__using__/1 macro.

Link to this function delete_user(item) View Source
delete_user(user()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}

deletes a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Examples

iex> delete_user(%Elixir.LazyContext.Examples.Users.Schemas.User{})
{:ok, %Elixir.LazyContext.Examples.Users.Schemas.User{}}
iex> delete_user(%Elixir.LazyContext.Examples.Users.Schemas.User{})
{:error, %Ecto.Changeset{}}

generated via the LazyContext.__using__/1 macro.

Link to this function delete_user!(item) View Source
delete_user!(user()) :: :user | no_return()

deletes a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Raises if deletion fails

Examples

iex> delete_user!(%Elixir.LazyContext.Examples.Users.Schemas.User{})
%Elixir.LazyContext.Examples.Users.Schemas.User{}

generated via the LazyContext.__using__/1 macro.

Link to this function get_user(attrs) View Source
get_user(map()) :: [user()] | nil
get_user(integer()) :: [user()] | nil

Gets a single %Elixir.LazyContext.Examples.Users.Schemas.User{} where the primary key matches the given ID, with [] preloaded.

Returns nil if no result was found. Raises if more than one result was found.

Examples

iex> get_user(123)
%Elixir.LazyContext.Examples.Users.Schemas.User{}

generated via the LazyContext.__using__/1 macro.

Link to this function get_user!(attrs) View Source
get_user!(map()) :: [user()] | no_return()
get_user!(integer()) :: [user()] | no_return()

Gets a single %Elixir.LazyContext.Examples.Users.Schemas.User{} where the primary key matches the given ID, with [] preloaded.

Raises if no result, or more than one result was found.

Examples

iex> get_user(123)
%Elixir.LazyContext.Examples.Users.Schemas.User{}

generated via the LazyContext.__using__/1 macro.

Link to this function list_users() View Source
list_users() :: [user()]

Returns a list of %Elixir.LazyContext.Examples.Users.Schemas.User{} with [] preloaded.

Examples

iex> list_users()
[%Elixir.LazyContext.Examples.Users.Schemas.User{}, ...]

generated via the LazyContext.__using__/1 macro.

Link to this function update_user(item, attrs) View Source
update_user(user(), map()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}

Updates a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Examples

iex> update_user(%Elixir.LazyContext.Examples.Users.Schemas.User{}, %{field: value})
{:ok, %Elixir.LazyContext.Examples.Users.Schemas.User{}}
iex> update_user(%Elixir.LazyContext.Examples.Users.Schemas.User{}, %{field: bad_value})
{:error, %Ecto.Changeset{}}

generated via the LazyContext.__using__/1 macro.

Link to this function update_user!(item, attrs) View Source
update_user!(user(), map()) :: user() | no_return()

Updates a %Elixir.LazyContext.Examples.Users.Schemas.User{}

Raises if the changeset is invalid

Examples

iex> update_user!(%Elixir.LazyContext.Examples.Users.Schemas.User{}, %{field: value})
%Elixir.LazyContext.Examples.Users.Schemas.User{}

generated via the LazyContext.__using__/1 macro.