Class: Eventosaurus::Models::Query
- Inherits:
-
Object
- Object
- Eventosaurus::Models::Query
- Defined in:
- lib/eventosaurus/models/query.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#partition_key_name ⇒ Object
readonly
Returns the value of attribute partition_key_name.
-
#partition_key_type ⇒ Object
readonly
Returns the value of attribute partition_key_type.
Instance Method Summary collapse
- #by_local_secondary(name:, value:, operator:) ⇒ Object
- #by_partition_key(value:, operator:) ⇒ Object
- #count ⇒ Object
-
#initialize(definition) ⇒ Query
constructor
A new instance of Query.
- #run ⇒ Object
- #select(attrs) ⇒ Object
Constructor Details
#initialize(definition) ⇒ Query
Returns a new instance of Query.
6 7 8 9 10 |
# File 'lib/eventosaurus/models/query.rb', line 6 def initialize(definition) @partition_key_name = definition[:partition_key].keys[0] @partition_key_type = definition[:partition_key].values[0] @args = { table_name: definition[:full_table_name] } end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/eventosaurus/models/query.rb', line 4 def args @args end |
#partition_key_name ⇒ Object (readonly)
Returns the value of attribute partition_key_name.
4 5 6 |
# File 'lib/eventosaurus/models/query.rb', line 4 def partition_key_name @partition_key_name end |
#partition_key_type ⇒ Object (readonly)
Returns the value of attribute partition_key_type.
4 5 6 |
# File 'lib/eventosaurus/models/query.rb', line 4 def partition_key_type @partition_key_type end |
Instance Method Details
#by_local_secondary(name:, value:, operator:) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/eventosaurus/models/query.rb', line 40 def by_local_secondary(name:, value:, operator:) @args[:query_filter] ||= {} @args[:query_filter][name] = { attribute_value_list: [value], comparison_operator: operator } self end |
#by_partition_key(value:, operator:) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/eventosaurus/models/query.rb', line 29 def by_partition_key(value:, operator:) @args[:key_conditions] = { partition_key_name => { attribute_value_list: [value], comparison_operator: operator } } self end |
#count ⇒ Object
23 24 25 26 27 |
# File 'lib/eventosaurus/models/query.rb', line 23 def count @args[:select] = 'COUNT' self end |
#run ⇒ Object
12 13 14 |
# File 'lib/eventosaurus/models/query.rb', line 12 def run Eventosaurus.configuration.dynamodb_client.query(args) end |
#select(attrs) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/eventosaurus/models/query.rb', line 16 def select(attrs) @args[:select] = 'SPECIFIC_ATTRIBUTES' @args[:attributes_to_get] = attrs self end |