Ecto v3.1.7 Ecto.Adapter.Queryable behaviour View Source

Specifies the query API required from adapters.

If your adapter is only able to respond to one or a couple of the query functions, add custom implementations of those functions directly to the Repo by using Ecto.Adapter.__before_compile__/1 instead.

Link to this section Summary

Types

Proxy type to the adapter meta

Cache query metadata

Ecto.Query metadata fields (stored in cache)

Functions

Plans a query using the given adapter.

Plans and prepares a query for the given repo, leveraging its query cache.

Callbacks

Commands invoked to prepare a query for all, update_all and delete_all.

Link to this section Types

Proxy type to the adapter meta

Link to this type

prepared() View Source
prepared() :: term()

Link to this type

query_cache() View Source
query_cache() ::
  {:nocache, prepared()}
  | {:cache, (cached() -> :ok), prepared()}
  | {:cached, (cached() -> :ok), (prepared() -> :ok), cached()}

Cache query metadata

Link to this type

query_meta() View Source
query_meta() :: %{sources: tuple(), preloads: term(), select: map()}

Ecto.Query metadata fields (stored in cache)

Link to this section Functions

Link to this function

plan_query(operation, adapter, queryable) View Source

Plans a query using the given adapter.

This does not expect the repository and therefore does not leverage the cache.

Link to this function

prepare_query(operation, repo_name_or_pid, queryable) View Source

Plans and prepares a query for the given repo, leveraging its query cache.

This operation uses the query cache if one is available.

Link to this section Callbacks

Link to this callback

execute(adapter_meta, query_meta, query_cache, params, options) View Source
execute(
  adapter_meta(),
  query_meta(),
  query_cache(),
  params :: list(),
  options()
) :: {integer(), [[term()]] | nil}

Executes a previously prepared query.

It must return a tuple containing the number of entries and the result set as a list of lists. The result set may also be nil if a particular operation does not support them.

The adapter_meta field is a map containing some of the fields found in the Ecto.Query struct.

Link to this callback

prepare(atom, query) View Source
prepare(atom :: :all | :update_all | :delete_all, query :: Ecto.Query.t()) ::
  {:cache, prepared()} | {:nocache, prepared()}

Commands invoked to prepare a query for all, update_all and delete_all.

The returned result is given to execute/6.

Link to this callback

stream(adapter_meta, query_meta, query_cache, params, options) View Source
stream(adapter_meta(), query_meta(), query_cache(), params :: list(), options()) ::
  Enumerable.t()

Streams a previously prepared query.

It returns a stream of values.

The adapter_meta field is a map containing some of the fields found in the Ecto.Query struct.