W3cubDocs

/Phoenix

Ecto.Adapter.Queryable behaviour

Specifies the query API required from adapters.

Summary

Types

adapter_meta()

Proxy type to the adapter meta

cached()
options()
prepared()
query_cache()

Cache query metadata

query_meta()

Ecto.Query metadata fields (stored in cache)

Functions

plan_query(operation, adapter, queryable)

Plans a query using the given adapter

prepare_query(operation, repo_name_or_pid, queryable)

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

Callbacks

execute(adapter_meta, query_meta, query_cache, params, options)

Executes a previously prepared query

prepare(atom, query)

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

stream(adapter_meta, query_meta, query_cache, params, options)

Streams a previously prepared query

Types

adapter_meta()

adapter_meta() :: Ecto.Adapter.adapter_meta()

Proxy type to the adapter meta

cached()

cached() :: term()

options()

options() :: Keyword.t()

prepared()

prepared() :: term()

query_cache()

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

Cache query metadata

query_meta()

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

Ecto.Query metadata fields (stored in cache)

Functions

plan_query(operation, adapter, queryable)

Plans a query using the given adapter.

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

prepare_query(operation, repo_name_or_pid, queryable)

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

This operation uses the query cache if one is available.

Callbacks

execute(adapter_meta, query_meta, query_cache, params, options)

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.

prepare(atom, query)

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.

stream(adapter_meta, query_meta, query_cache, params, options)

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.

© 2012 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/ecto/Ecto.Adapter.Queryable.html