ecto_shorts v1.1.0 EctoShorts.SchemaHelpers View Source
Module that has helpers that are globably useful on ecto schemas
Link to this section Summary
Functions
Determine if all items in list has been created or not
Determine if all items in list are a schema
Determine if any items in list has been created or not
Determine if item has been created or not
Determine if any items in list are a schema
Determine if item passed in is a Ecto Schema
Link to this section Functions
all_created?(items)
View Source
all_created?([Ecto.Schema.t() | any()]) :: boolean()
all_created?([Ecto.Schema.t() | any()]) :: boolean()
Determine if all items in list has been created or not
Example
iex> SchemaHelpers.all_created?([%{id: 2}, %{"id" => 5}]) true iex> SchemaHelpers.all_created?([%{"id" => 2}, %{item: 3}]) false
all_schemas?(items)
View Source
all_schemas?([Ecto.Schema.t() | any()]) :: boolean()
all_schemas?([Ecto.Schema.t() | any()]) :: boolean()
Determine if all items in list are a schema
Example
iex> SchemaHelpers.all_schemas([%{some_map: 1}, create_schema()]) false iex> SchemaHelpers.all_schemas([create_schema(), create_schema()]) true
any_created?(items)
View Source
any_created?([Ecto.Schema.t() | any()]) :: boolean()
any_created?([Ecto.Schema.t() | any()]) :: boolean()
Determine if any items in list has been created or not
Example
iex> SchemaHelpers.any_created?([%{id: 2}, %{"id" => 5}]) true iex> SchemaHelpers.any_created?([%{"id" => 2}, %{item: 3}]) true iex> SchemaHelpers.any_created?([%{test: 3}, %{item: 3}]) false
created?(arg1)
View Source
created?(Ecto.Schema.t() | any()) :: boolean()
created?(Ecto.Schema.t() | any()) :: boolean()
Determine if item has been created or not
Example
iex> SchemaHelpers.created?(%{id: 2}) true iex> SchemaHelpers.created?(%{"id" => 2}) true iex> SchemaHelpers.created?(%{item: 3}) false
has_schemas?(items)
View Source
has_schemas?([Ecto.Schema.t() | any()]) :: boolean()
has_schemas?([Ecto.Schema.t() | any()]) :: boolean()
Determine if any items in list are a schema
Example
iex> SchemaHelpers.has_schemas?([%{some_map: 1}, create_schema()]) true iex> SchemaHelpers.has_schemas?([%{some_map: 1}]) false
schema?(arg1)
View Source
schema?(Ecto.Schema.t() | any()) :: boolean()
schema?(Ecto.Schema.t() | any()) :: boolean()
Determine if item passed in is a Ecto Schema
Example
iex> SchemaHelpers.schema?(create_schema()) true iex> SchemaHelpers.schema?(%{some_map: 1}) false iex> SchemaHelpers.schema?([create_schema()]) false