Ecto.Adapters.DynamoDB.Query (ecto_adapters_dynamodb v3.1.2) View Source

Some query wrapper functions for helping us query dynamo db. Selects indexes to use, etc. Not to be confused with Ecto.Query.

Link to this section Summary

Functions

Given a map with a search criteria, finds the best index to search against it. Returns a tuple indicating whether it's a primary key index, or a secondary index. To query against a secondary index in Dynamo, we NEED to have it's index name, so secondary indexes are returned as a tuple with the field name, whilst the primary key uses the atom :primary to distinguish it.

Same as get_best_index, but refers to a scan option on failure

Given a search criteria of 1 or more fields, we try find out if the primary key is a good match and can be used to forfill this search. Returns the tuple {:primary, [hash] | [hash, range]} or :not_found

Given a keyword list containing search field, value and operator to search for (which may also be nested under logical operators, e.g., [{"id", {"franko", :==}}], or [{:and, [{"circle_id", {"123", :==}}, {"person_id", {"abc", :>}}]}), will return the dynamo db index description that will help us match this search. return :not_found if no index is found.

Formats the recursive option according to whether the query is a DynamoDB scan or query. (The adapter defaults to recursive fetch in case of the latter but not the former)

Returns an atom, :scan or :query, specifying whether the current search will be a DynamoDB scan or a query.

Updates the recursive option during a recursive fetch, according to whether the option is a boolean or an integer (as in the case of page_limit)

Link to this section Types

Specs

expression_data_acc() :: {[String.t()], map(), map()}

Link to this section Functions

Link to this function

construct_search(arg, search, opts)

View Source

Specs

construct_search(
  {:primary | :primary_partial | nil | String.t(), [String.t()]},
  search(),
  keyword()
) :: keyword()
construct_search(
  {:secondary_partial, String.t(), [String.t()]},
  search(),
  keyword()
) :: keyword()
Link to this function

get_best_index(repo, tablename, search, opts)

View Source

Specs

get_best_index(Ecto.Repo.t(), table_name(), search(), query_opts()) ::
  :not_found
  | {:primary, [String.t()]}
  | {:primary_partial, [String.t()]}
  | {String.t(), [String.t()]}
  | {:secondary_partial, String.t(), [String.t()]}
  | no_return()

Given a map with a search criteria, finds the best index to search against it. Returns a tuple indicating whether it's a primary key index, or a secondary index. To query against a secondary index in Dynamo, we NEED to have it's index name, so secondary indexes are returned as a tuple with the field name, whilst the primary key uses the atom :primary to distinguish it.

| {"index_name", [indexed_fields_list]}

Exception if the index doesn't exist.

Link to this function

get_best_index!(repo, tablename, search, opts \\ [])

View Source

Same as get_best_index, but refers to a scan option on failure

Link to this function

get_item(repo, table, search, opts)

View Source

Specs

get_item(Ecto.Repo.t(), table_name(), search(), keyword()) ::
  dynamo_response() | no_return()
Link to this function

get_matching_primary_index(repo, tablename, search)

View Source

Given a search criteria of 1 or more fields, we try find out if the primary key is a good match and can be used to forfill this search. Returns the tuple {:primary, [hash] | [hash, range]} or :not_found

Link to this function

get_matching_secondary_index(repo, tablename, search, opts)

View Source

Given a keyword list containing search field, value and operator to search for (which may also be nested under logical operators, e.g., [{"id", {"franko", :==}}], or [{:and, [{"circle_id", {"123", :==}}, {"person_id", {"abc", :>}}]}), will return the dynamo db index description that will help us match this search. return :not_found if no index is found.

Returns a tuple of {"index_name", [ hash_key or hash,range_key]]} or :not_found TODO: Does not help with range queries. -> The match_index_hash_part function is beginning to address this.

Link to this function

parse_recursive_option(scan_or_query, opts)

View Source

Formats the recursive option according to whether the query is a DynamoDB scan or query. (The adapter defaults to recursive fetch in case of the latter but not the former)

Link to this function

scan_or_query?(repo, table, search)

View Source

Returns an atom, :scan or :query, specifying whether the current search will be a DynamoDB scan or a query.

Link to this function

update_recursive_option(r)

View Source

Updates the recursive option during a recursive fetch, according to whether the option is a boolean or an integer (as in the case of page_limit)