Module: TinyDyno::HashKey
- Extended by:
- ActiveSupport::Concern
- Included in:
- DocumentComposition
- Defined in:
- lib/tiny_dyno/hash_key.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#keys_as_selector ⇒ Object
return all defined hash keys on an instantiated object for further use in DynamoDB queries, i.e.
Instance Method Details
#keys_as_selector ⇒ Object
return all defined hash keys on an instantiated object for further use in DynamoDB queries, i.e. to look up an object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tiny_dyno/hash_key.rb', line 18 def keys_as_selector selector = {} primary_key_field = self.class.primary_key[:attribute_name] selector[primary_key_field.to_sym] = TinyDyno::Adapter.aws_attribute(field_type: fields[primary_key_field].[:type], value: attributes[primary_key_field]) unless range_key.empty? range_key_field = self.class.range_key[:attribute_name] selector[range_key_field.to_sym] = TinyDyno::Adapter.aws_attribute(field_type: fields[range_key_field].[:type], value: attributes[range_key_field]) end return nil if selector.empty? selector end |