LazyContext v0.1.2-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.
Examples
iex> change_user(%Elixir.LazyContext.Examples.Users.Schemas.User{}, %{field: value}) %Ecto.Changeset{}
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
(%{})
Examples
iex> create_user() {:ok, %Elixir.LazyContext.Examples.Users.Schemas.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 section Functions
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.