appfuel 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f74bbf3635efafded1ca260d1281ba756b1eee15
4
- data.tar.gz: 25ed32bc0ddaf5b13338a600433bbb916cf3fcfd
3
+ metadata.gz: c62c1dda23c68cc94510cc7d066289d8096ccec4
4
+ data.tar.gz: 38778f084abf8373397920e12b2fbe7d90ec1567
5
5
  SHA512:
6
- metadata.gz: 2ee094890d79beb03dca5b6c4e1d6876d658424386d1afd190729bdf3e836f97306505a0d04f3eff9fcc08ab1fa59e7a83bb865c7cf33a963ca30c6a6befceb3
7
- data.tar.gz: 0363de28ffd4385cc8cd490f35f9567d972ca1cc945a139d7bd6895d26b69e4425ff1a4b877c9914bfe4a21eb60f2c6536b0ecd3f364c5b84c9bde0695ada289
6
+ metadata.gz: a8b4f1093b76c7be1b9c6db79cc0a6ae40fc085c8f99cb2ed78c4eabda6fe6646c9f71ea8627dcf9e8726feac5cdde8d0a2d9098ce53dee5a0b4b427a4ff27a9
7
+ data.tar.gz: 7976bd1967ce72901ac38491b4e775c87a15e084b21386b96ea91d626934c1cf6f445b2cc226084e0c1fca4c6d009e42bb43885a94e6d40dfd007e817e9dea0f
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. (Pending ap
5
5
 
6
6
 
7
7
  # Releases
8
+ ## [[0.6.6]](https://github.com/rsb/appfuel/releases/tag/0.6.6) 2017-08-23
9
+ ### Added
10
+ - `batch_get` to dynamodb nosql adapter
11
+
8
12
  ## [[0.6.5]](https://github.com/rsb/appfuel/releases/tag/0.6.5) 2017-08-21
9
13
  ### Added
10
14
  - basic table query interface for dynamodb nosql adapter
@@ -101,7 +101,6 @@ module Appfuel
101
101
  self.class.primary_key
102
102
  end
103
103
 
104
-
105
104
  def put_params(data)
106
105
  create_table_hash(item: data)
107
106
  end
@@ -152,6 +151,49 @@ module Appfuel
152
151
  client.query(params)
153
152
  end
154
153
 
154
+ def batch_keys(ids)
155
+ fail "ids must response to :map" unless ids.respond_to?(:map)
156
+ key = primary_key
157
+ ids.map do |id|
158
+ hash_value, range_value = id.is_a?(Array)? id : [id, nil]
159
+ key.params(hash_value, range_value)
160
+ end
161
+ end
162
+
163
+ # build batch keys
164
+ # when inputs is an array of one item
165
+ # when the inputs is an array of two items
166
+ #
167
+ # requested_items: {
168
+ # "TableName" => {
169
+ # keys: [
170
+ #
171
+ # ]
172
+ # }
173
+ # }
174
+ #
175
+ #
176
+ def batch_get(ids, &block)
177
+ table_key = table_name
178
+ result = client.batch_get_item(
179
+ request_items: {
180
+ table_key => { keys: batch_keys(ids) }
181
+ }
182
+ )
183
+
184
+
185
+ unless result.responses.key?(table_key)
186
+ fail "db table name #{table_key} is not correct"
187
+ end
188
+
189
+ list = result.responses[table_key]
190
+ return list if block_given?
191
+
192
+ list.each do |item|
193
+ yield item
194
+ end
195
+ end
196
+
155
197
  def put(data)
156
198
  params = put_params(data)
157
199
  client.put_item(params)
@@ -1,3 +1,3 @@
1
1
  module Appfuel
2
- VERSION = "0.6.5"
2
+ VERSION = "0.6.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appfuel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Scott-Buccleuch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-21 00:00:00.000000000 Z
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord