CommandedAggregateless.Query behaviour (commanded_aggregateless v1.0.0)

Copy Markdown

Provides common functionality for the execution of queries against the read store

Example:

defmodule CommandedAggregateless.TestQuery do
  use CommandedAggregateless.Query, repo: CommandedAggregateless.ReadOnlyRepo, repo_fn: :all

  inputs do
    field :foo, :string
  end

  validates(:foo, string: true)

  def to_query(_query) do
    from t in TestProjection, select: t
  end
end

Summary

Callbacks

Callback that allows a query to manipulate the results before they are returned.

Functions

Sets up a query module for use with the CommandedAggregateless.Query.QueryOps protocol.

Executes the query against the read store.

Defines the inputs to the query.

Types

error()

@type error() :: validation_error()

repo_fn_result()

@type repo_fn_result() ::
  term()
  | nil
  | [Ecto.Schema.t() | term()]
  | boolean()
  | Ecto.Schema.t()
  | Enum.t()

result()

result(type)

@type result(type) :: CommandedAggregateless.result(type, validation_error())

t()

validation_error()

@type validation_error() :: {:invalid_query, keyword(String.t())}

Callbacks

handle_result(result, t)

@callback handle_result(result(), t()) :: result()

Callback that allows a query to manipulate the results before they are returned.

A default implementation that simply returns the result unchanged is provided when using use CommandedAggregateless.Query.

to_query(t)

@callback to_query(t()) :: Ecto.Query.t()

Functions

__using__(opts \\ [])

(macro)
@spec __using__(keyword()) :: Macro.t()

Sets up a query module for use with the CommandedAggregateless.Query.QueryOps protocol.

See module documentation for an example.

execute(query)

Executes the query against the read store.

inputs(arg1)

(macro)
@spec inputs(:none | [{:do, Macro.t()}]) :: Macro.t()

Defines the inputs to the query.

See module documentation for an example.