Module: DynamodbRecord::Query::ClassMethods
- Defined in:
- lib/dynamodb_record/query.rb
Overview
Module that provides class methods for queries against the DynamoDB database.
Instance Method Summary collapse
- #all(opts = {}) ⇒ Object
-
#where(opts = {}) ⇒ Object
search table.
Instance Method Details
#all(opts = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/dynamodb_record/query.rb', line 10 def all(opts = {}) = .merge!(opts.slice(:limit)) scan_pager = ScanPager.new(, self) Collection.new(scan_pager, self) end |
#where(opts = {}) ⇒ Object
search table
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dynamodb_record/query.rb', line 19 def where(opts = {}) limit = opts.delete(:limit) exclusive_start_key = opts.delete(:exclusive_start_key) expression_attribute_names = {} expression_attribute_values = {} filter_expression = '' opts.each do |key, value| expression_attribute_names[:"##{key}"] = key.to_s expression_attribute_values[":#{key}"] = value filter_expression << if filter_expression.empty? "##{key} = :#{key}" else " And ##{key} = :#{key}" end end = .merge!(limit:) if limit .merge!(expression_attribute_names:) if expression_attribute_names.present? .merge!(expression_attribute_values:) if expression_attribute_values.present? .merge!(filter_expression:) if filter_expression.present? .merge!(exclusive_start_key:) if exclusive_start_key # p options scan_pager = ScanPager.new(, self) Collection.new(scan_pager, self) # DynamodbRecord::Collection.new(client.scan(options), self) end |