Class: Dynomite::Item::Query::Params::KeyCondition

Inherits:
Base
  • Object
show all
Defined in:
lib/dynomite/item/query/params/key_condition.rb

Constant Summary

Constants included from Types

Types::TYPE_MAP

Instance Method Summary collapse

Methods inherited from Base

#expression_string, #function_names, #join_expressions

Methods included from Helpers

#all_where_field_names, #all_where_fields, #disable_index_for_any_or?, #disable_index_for_consistent_read?, #disable_index_for_not?, #normalize_expression_path, #normalize_project_expression, #query, #scan_required?, #with_where_groups

Methods included from Types

#type_map

Constructor Details

#initialize(relation, index, partition_key_field, sort_key_field) ⇒ KeyCondition

Returns a new instance of KeyCondition.



3
4
5
6
# File 'lib/dynomite/item/query/params/key_condition.rb', line 3

def initialize(relation, index, partition_key_field, sort_key_field)
  @relation, @index, @partition_key_field, @sort_key_field = relation, index, partition_key_field, sort_key_field
  @expressions = []
end

Instance Method Details

#buildObject



13
14
15
16
17
18
19
20
21
# File 'lib/dynomite/item/query/params/key_condition.rb', line 13

def build
  with_where_groups do |where_group|
    expression = where_group.build_compare_expression_if do |field|
      @index.fields.include?(field)
    end
    next unless expression
    @expressions << expression
  end
end

#expressionObject



8
9
10
11
# File 'lib/dynomite/item/query/params/key_condition.rb', line 8

def expression
  build
  join_expressions
end

#full_primary_key_in_query?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
# File 'lib/dynomite/item/query/params/key_condition.rb', line 24

def full_primary_key_in_query?
  field_names = all_where_field_names
  if @sort_key_field
    field_names.include?(@sort_key_field) && field_names.include?(@partition_key_field)
  else
    field_names.include?(@partition_key_field)
  end
end