Ecto v3.1.4 Ecto.Adapter.Schema behaviour View Source
Specifies the schema API required from adapters.
Link to this section Summary
Callbacks
Called to autogenerate a value for id/embed_id/binary_id.
Deletes a single struct with the given filters.
Inserts a single new struct in the data store.
Inserts multiple entries into the data store.
Updates a single struct with the given filters.
Link to this section Types
adapter_meta()
View Source
adapter_meta() :: Ecto.Adapter.adapter_meta()
adapter_meta() :: Ecto.Adapter.adapter_meta()
Proxy type to the adapter meta
constraints()
View Source
constraints() :: Keyword.t()
constraints() :: Keyword.t()
fields()
View Source
fields() :: Keyword.t()
fields() :: Keyword.t()
filters()
View Source
filters() :: Keyword.t()
filters() :: Keyword.t()
on_conflict() View Source
options()
View Source
options() :: Keyword.t()
options() :: Keyword.t()
returning()
View Source
returning() :: [atom()]
returning() :: [atom()]
schema_meta() View Source
Ecto.Schema metadata fields
Link to this section Callbacks
autogenerate(field_type)
View Source
autogenerate(field_type :: :id | :binary_id | :embed_id) :: term() | nil
autogenerate(field_type :: :id | :binary_id | :embed_id) :: term() | nil
Called to autogenerate a value for id/embed_id/binary_id.
Returns the autogenerated value, or nil if it must be autogenerated inside the storage or raise if not supported.
delete(adapter_meta, schema_meta, filters, options)
View Source
delete(adapter_meta(), schema_meta(), filters(), options()) ::
{:ok, fields()} | {:invalid, constraints()} | {:error, :stale}
delete(adapter_meta(), schema_meta(), filters(), options()) :: {:ok, fields()} | {:invalid, constraints()} | {:error, :stale}
Deletes a single struct with the given filters.
While filters
can be any record column, it is expected that
at least the primary key (or any other key that uniquely
identifies an existing record) be given as a filter. Therefore,
in case there is no record matching the given filters,
{:error, :stale}
is returned.
insert(adapter_meta, schema_meta, fields, on_conflict, returning, options)
View Source
insert(
adapter_meta(),
schema_meta(),
fields(),
on_conflict(),
returning(),
options()
) :: {:ok, fields()} | {:invalid, constraints()}
insert( adapter_meta(), schema_meta(), fields(), on_conflict(), returning(), options() ) :: {:ok, fields()} | {:invalid, constraints()}
Inserts a single new struct in the data store.
Autogenerate
The primary key will be automatically included in returning
if the
field has type :id
or :binary_id
and no value was set by the
developer or none was autogenerated by the adapter.
insert_all(adapter_meta, schema_meta, header, list, on_conflict, returning, options)
View Source
insert_all(
adapter_meta(),
schema_meta(),
header :: [atom()],
[[{atom(), term() | {Ecto.Query.t(), list()}}]],
on_conflict(),
returning(),
options()
) :: {integer(), [[term()]] | nil}
insert_all( adapter_meta(), schema_meta(), header :: [atom()], [[{atom(), term() | {Ecto.Query.t(), list()}}]], on_conflict(), returning(), options() ) :: {integer(), [[term()]] | nil}
Inserts multiple entries into the data store.
In case an Ecto.Query
given as any of the field values by the user,
it will be sent to the adapter as a tuple with in the shape of
{query, params}
.
update(adapter_meta, schema_meta, fields, filters, returning, options)
View Source
update(
adapter_meta(),
schema_meta(),
fields(),
filters(),
returning(),
options()
) :: {:ok, fields()} | {:invalid, constraints()} | {:error, :stale}
update( adapter_meta(), schema_meta(), fields(), filters(), returning(), options() ) :: {:ok, fields()} | {:invalid, constraints()} | {:error, :stale}
Updates a single struct with the given filters.
While filters
can be any record column, it is expected that
at least the primary key (or any other key that uniquely
identifies an existing record) be given as a filter. Therefore,
in case there is no record matching the given filters,
{:error, :stale}
is returned.