LazyContext v0.1.4-dev LazyContext.Examples.Animals View Source
An example context to demonstrate features the LazyContext library
Link to this section Summary
Functions
Returns a data structure for tracking %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
changes
Returns a data structure for tracking %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
changes
Returns a data structure for tracking %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
changes
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
, if valid. Equivalent to calling create_cat
(%{})
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
, if valid. Equivalent to calling create_cat!
(%{})
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
, if valid. Equivalent to calling create_dog
(%{})
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
, if valid. Equivalent to calling create_dog!
(%{})
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
, if valid. Equivalent to calling create_ferret
(%{})
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
, if valid. Equivalent to calling create_ferret!
(%{})
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
if it already exists, otherwise creates one
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
if it already exists, otherwise creates one
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
if it already exists, otherwise creates one
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
if it already exists, otherwise creates one
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
if it already exists, otherwise creates one
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
if it already exists, otherwise creates one
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
where the primary key matches the given ID, with [:owner]
preloaded
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
where the primary key matches the given ID, with [:owner]
preloaded
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
where the primary key matches the given ID, with [:owner]
preloaded
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
where the primary key matches the given ID, with [:owner]
preloaded
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
where the primary key matches the given ID, with [:owner]
preloaded
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
where the primary key matches the given ID, with [:owner]
preloaded
Returns a list of %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
with []
preloaded
Returns a list of %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
with [:owner]
preloaded
Returns a list of %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
with [:owner]
preloaded
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Link to this section Types
Link to this section Functions
change_cat(cat(), map()) :: Ecto.Changeset.t()
Returns a data structure for tracking %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
changes.
Examples
iex> change_cat(%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}, %{field: value})
%Ecto.Changeset{}
generated via the LazyContext.__using__/1
macro.
change_dog(dog(), map()) :: Ecto.Changeset.t()
Returns a data structure for tracking %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
changes.
Examples
iex> change_dog(%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}, %{field: value})
%Ecto.Changeset{}
generated via the LazyContext.__using__/1
macro.
change_ferret(ferret(), map()) :: Ecto.Changeset.t()
Returns a data structure for tracking %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
changes.
Examples
iex> change_ferret(%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}, %{field: value})
%Ecto.Changeset{}
generated via the LazyContext.__using__/1
macro.
create_cat() :: {:ok, cat()} | {:error, Ecto.Changeset.t()}
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
, if valid. Equivalent to calling create_cat
(%{})
Examples
iex> create_cat()
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}}
generated via the LazyContext.__using__/1
macro.
create_cat(map()) :: {:ok, cat()} | {:error, Ecto.Changeset.t()}
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Examples
iex> create_cat(%{field: value})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}}
iex> create_cat(%{field: bad_value})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
, if valid. Equivalent to calling create_cat!
(%{})
Raises if the changeset is invalid.
Examples
iex> create_cat!()
%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
generated via the LazyContext.__using__/1
macro.
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Raises if the changeset is invalid.
Examples
iex> create_cat!(%{field: value})
%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
generated via the LazyContext.__using__/1
macro.
create_dog() :: {:ok, dog()} | {:error, Ecto.Changeset.t()}
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
, if valid. Equivalent to calling create_dog
(%{})
Examples
iex> create_dog()
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}}
generated via the LazyContext.__using__/1
macro.
create_dog(map()) :: {:ok, dog()} | {:error, Ecto.Changeset.t()}
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Examples
iex> create_dog(%{field: value})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}}
iex> create_dog(%{field: bad_value})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
, if valid. Equivalent to calling create_dog!
(%{})
Raises if the changeset is invalid.
Examples
iex> create_dog!()
%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
generated via the LazyContext.__using__/1
macro.
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Raises if the changeset is invalid.
Examples
iex> create_dog!(%{field: value})
%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
generated via the LazyContext.__using__/1
macro.
create_ferret() :: {:ok, ferret()} | {:error, Ecto.Changeset.t()}
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
, if valid. Equivalent to calling create_ferret
(%{})
Examples
iex> create_ferret()
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}}
generated via the LazyContext.__using__/1
macro.
create_ferret(map()) :: {:ok, ferret()} | {:error, Ecto.Changeset.t()}
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Examples
iex> create_ferret(%{field: value})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}}
iex> create_ferret(%{field: bad_value})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
Creates an “empty” %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
, if valid. Equivalent to calling create_ferret!
(%{})
Raises if the changeset is invalid.
Examples
iex> create_ferret!()
%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
generated via the LazyContext.__using__/1
macro.
Creates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Raises if the changeset is invalid.
Examples
iex> create_ferret!(%{field: value})
%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
generated via the LazyContext.__using__/1
macro.
create_or_update_cat(map()) :: {:ok, cat()} | {:error, Ecto.Changeset.t()}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
if it already exists, otherwise creates one.
Whether a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
already exists is determined by a lookup on the following fields: [:id]
Examples
iex> create_or_updatecat(%{field: value})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}}
iex> create_cat(%{field: bad_value})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
if it already exists, otherwise creates one.
Whether a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
already exists is determined by a lookup on the following fields: [:id]
Raises if the changeset is invalid
Examples
iex> create_or_updatecat!(%{field: value})
%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
generated via the LazyContext.__using__/1
macro.
create_or_update_dog(map()) :: {:ok, dog()} | {:error, Ecto.Changeset.t()}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
if it already exists, otherwise creates one.
Whether a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
already exists is determined by a lookup on the following fields: [:id]
Examples
iex> create_or_updatedog(%{field: value})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}}
iex> create_dog(%{field: bad_value})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
if it already exists, otherwise creates one.
Whether a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
already exists is determined by a lookup on the following fields: [:id]
Raises if the changeset is invalid
Examples
iex> create_or_updatedog!(%{field: value})
%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
generated via the LazyContext.__using__/1
macro.
create_or_update_ferret(map()) :: {:ok, ferret()} | {:error, Ecto.Changeset.t()}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
if it already exists, otherwise creates one.
Whether a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
already exists is determined by a lookup on the following fields: [:social_security_number]
Examples
iex> create_or_updateferret(%{field: value})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}}
iex> create_ferret(%{field: bad_value})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
if it already exists, otherwise creates one.
Whether a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
already exists is determined by a lookup on the following fields: [:social_security_number]
Raises if the changeset is invalid
Examples
iex> create_or_updateferret!(%{field: value})
%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
generated via the LazyContext.__using__/1
macro.
delete_cat(cat()) :: {:ok, cat()} | {:error, Ecto.Changeset.t()}
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Examples
iex> delete_cat(%Elixir.LazyContext.Examples.Animals.Schemas.Cat{})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}}
iex> delete_cat(%Elixir.LazyContext.Examples.Animals.Schemas.Cat{})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Raises if deletion fails
Examples
iex> delete_cat!(%Elixir.LazyContext.Examples.Animals.Schemas.Cat{})
%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
generated via the LazyContext.__using__/1
macro.
delete_dog(dog()) :: {:ok, dog()} | {:error, Ecto.Changeset.t()}
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Examples
iex> delete_dog(%Elixir.LazyContext.Examples.Animals.Schemas.Dog{})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}}
iex> delete_dog(%Elixir.LazyContext.Examples.Animals.Schemas.Dog{})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Raises if deletion fails
Examples
iex> delete_dog!(%Elixir.LazyContext.Examples.Animals.Schemas.Dog{})
%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
generated via the LazyContext.__using__/1
macro.
delete_ferret(ferret()) :: {:ok, ferret()} | {:error, Ecto.Changeset.t()}
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Examples
iex> delete_ferret(%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}}
iex> delete_ferret(%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
deletes a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Raises if deletion fails
Examples
iex> delete_ferret!(%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{})
%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
generated via the LazyContext.__using__/1
macro.
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
where the primary key matches the given ID, with [:owner]
preloaded.
Returns nil
if no result was found. Raises if more than one result was found.
Examples
iex> get_cat(123)
%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
generated via the LazyContext.__using__/1
macro.
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
where the primary key matches the given ID, with [:owner]
preloaded.
Raises if no result, or more than one result was found.
Examples
iex> get_cat(123)
%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
generated via the LazyContext.__using__/1
macro.
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
where the primary key matches the given ID, with [:owner]
preloaded.
Returns nil
if no result was found. Raises if more than one result was found.
Examples
iex> get_dog(123)
%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
generated via the LazyContext.__using__/1
macro.
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
where the primary key matches the given ID, with [:owner]
preloaded.
Raises if no result, or more than one result was found.
Examples
iex> get_dog(123)
%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
generated via the LazyContext.__using__/1
macro.
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
where the primary key matches the given ID, with [:owner]
preloaded.
Returns nil
if no result was found. Raises if more than one result was found.
Examples
iex> get_ferret(123)
%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
generated via the LazyContext.__using__/1
macro.
Gets a single %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
where the primary key matches the given ID, with [:owner]
preloaded.
Raises if no result, or more than one result was found.
Examples
iex> get_ferret(123)
%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
generated via the LazyContext.__using__/1
macro.
Returns a list of %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
with []
preloaded.
Examples
iex> list_cats()
[%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}, ...]
generated via the LazyContext.__using__/1
macro.
Returns a list of %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
with [:owner]
preloaded.
Examples
iex> list_doggos()
[%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}, ...]
generated via the LazyContext.__using__/1
macro.
Returns a list of %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
with [:owner]
preloaded.
Examples
iex> list_ferrets()
[%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}, ...]
generated via the LazyContext.__using__/1
macro.
update_cat(cat(), map()) :: {:ok, cat()} | {:error, Ecto.Changeset.t()}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Examples
iex> update_cat(%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}, %{field: value})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}}
iex> update_cat(%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}, %{field: bad_value})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
Raises if the changeset is invalid
Examples
iex> update_cat!(%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}, %{field: value})
%Elixir.LazyContext.Examples.Animals.Schemas.Cat{}
generated via the LazyContext.__using__/1
macro.
update_dog(dog(), map()) :: {:ok, dog()} | {:error, Ecto.Changeset.t()}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Examples
iex> update_dog(%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}, %{field: value})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}}
iex> update_dog(%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}, %{field: bad_value})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
Raises if the changeset is invalid
Examples
iex> update_dog!(%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}, %{field: value})
%Elixir.LazyContext.Examples.Animals.Schemas.Dog{}
generated via the LazyContext.__using__/1
macro.
update_ferret(ferret(), map()) :: {:ok, ferret()} | {:error, Ecto.Changeset.t()}
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Examples
iex> update_ferret(%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}, %{field: value})
{:ok, %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}}
iex> update_ferret(%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}, %{field: bad_value})
{:error, %Ecto.Changeset{}}
generated via the LazyContext.__using__/1
macro.
Updates a %Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
Raises if the changeset is invalid
Examples
iex> update_ferret!(%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}, %{field: value})
%Elixir.LazyContext.Examples.Animals.Schemas.Ferret{}
generated via the LazyContext.__using__/1
macro.