ecto_adapters_dynamodb v0.5.0 Ecto.Adapters.DynamoDB.Query 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

Link to this type expression_data_acc() View Source
expression_data_acc() :: {[String.t()], map(), map()}

Link to this section Functions

Link to this function construct_search(arg, search, opts) View Source
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 filter(results, search) View Source
filter(dynamo_response(), search()) :: dynamo_response()
Link to this function get_best_index(tablename, search) View Source
get_best_index(table_name(), search()) ::
  :not_found
  | {:primary, [String.t()]}
  | {:primary_partial, [String.t()]}
  | {String.t(), [String.t()]}

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.

{:primary, [indexed_fields_list]} | {“index_name”, [indexed_fields_list]}

Exception if the index doesn’t exist.

Link to this function get_best_index!(tablename, search) View Source

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

Link to this function get_item(table, search, opts) View Source
get_item(table_name(), search(), keyword()) :: dynamo_response() | no_return()
Link to this function get_matching_primary_index(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(tablename, search) 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?(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)