dynamodb-api 0.7.0 → 0.8.0

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
  SHA256:
3
- metadata.gz: dbaea71109e5f59f3371de8c33d10a26e23855e6666c6e71d4c3fe46cd6f9818
4
- data.tar.gz: 58b5b94c50002c02605e46eb75aeec66a2f8f38339f34d074fa23d16cf13f80d
3
+ metadata.gz: f399f21ab0ac3eb7d980389fbf500772d9d39dbdd60b3220cc2b0cbd3adc4a6d
4
+ data.tar.gz: 6a226aa3af37bef462f46a257e3206be4a6c5529b7dc44994f20737190aa2616
5
5
  SHA512:
6
- metadata.gz: 5ba6e2154406a24eec7aa3a806b5901c6216c2cfa3f74ea00ded9c0849b8e272933d8f4bd92d2b20417e284815273046a1eb575cab7765e7eb6523493ea204c8
7
- data.tar.gz: a31a6a368d48914534eb50d9055a6d6b6fa1ee3ae3edb95039f189caf047b635612f798ad012b32afa6c48c26d4e21025b57eeb193c683ad43bbd1a84de2717d
6
+ metadata.gz: 58976b0b20a9476ed7d53c56e493caa02701e4d3d2ca09eee87356e34d737558e9bce42b74c24799eb1470344d0286b891af6a97c4e8fe7c8ec4f1c272b3a761
7
+ data.tar.gz: 3f3e5af9e0afc031d122dbb0634d85c8349057ce38a04c248c5126676e4c7cc48e1bcb66943ae27470f2a7fef4d2335eef0393dc786165c4fb5c3f46ed66f7f8
data/.travis.yml CHANGED
@@ -4,11 +4,17 @@ rvm:
4
4
  - 2.3
5
5
  - 2.4
6
6
  - 2.5
7
+ - 2.6
7
8
  gemfile:
8
9
  - gemfiles/aws_sdk_2.gemfile
9
10
  - gemfiles/aws_sdk_3.gemfile
10
11
 
11
- before_install: gem install bundler -v 1.16.2
12
+ before_install:
13
+ - |
14
+ if [[ ${RUBY_VERSION} =~ ^ruby-2.3 ]]; then
15
+ gem uninstall -i /home/travis/.rvm/gems/${RUBY_VERSION}@global bundler -x
16
+ fi
17
+ - gem install bundler -v 1.16.2
12
18
 
13
19
  before_script:
14
20
  - docker-compose up -d
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ---
10
+
11
+ ## [0.8.0] - 2019-03-03
12
+ ### Added
13
+ - [#39](https://github.com/walkersumida/dynamodb-api/pull/39) `next` method
14
+
9
15
  ## [0.7.0] - 2018-12-23
10
16
  ### Added
11
17
  - [#34](https://github.com/walkersumida/dynamodb-api/pull/34) `scan` method
data/README.md CHANGED
@@ -74,6 +74,22 @@ items = scan.all.items
74
74
  |3 |3 |Model S |0.20120601e8 |0 |
75
75
  |4 |1 |S2000 |0.19980101e8 |1 |
76
76
 
77
+
78
+ #### Next(Paging) [Unreleased]
79
+
80
+ ```ruby
81
+ scan = Dynamodb::Api.scan
82
+ scan.from('cars').
83
+ limit(1)
84
+ _items = scan.all.items
85
+ items = scan.next.items
86
+ ```
87
+
88
+ | id | maker_id(Partition key) | model | release_date(Sort key) | status |
89
+ |:---|:---|:---|:---|:---|
90
+ |2 |2 |CROWN |0.19550101e8 |0 |
91
+
92
+
77
93
  ### Query
78
94
  https://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#query-instance_method
79
95
 
@@ -148,6 +164,22 @@ items = query.all.items
148
164
  |:---|:---|:---|:---|:---|
149
165
  |1 |1 |Accord |0.19760508e8 |0 |
150
166
 
167
+ #### Next(Paging) [Unreleased]
168
+
169
+ ```ruby
170
+ query = Dynamodb::Api.query
171
+ query.from('cars').index('index_maker_id_release_date').
172
+ where(['maker_id', '=', 1]).
173
+ order('asc'). # default: 'desc'
174
+ limit(1)
175
+ _items = query.all.items
176
+ items = query.next.items
177
+ ```
178
+
179
+ | id | maker_id(Partition key) | model | release_date(Sort key) | status |
180
+ |:---|:---|:---|:---|:---|
181
+ |4 |1 |S2000 |0.19980101e8 |1 |
182
+
151
183
  #### Expression Attribute Names
152
184
 
153
185
  Words reserved in DynamoDB can not be used without special processing.
@@ -6,6 +6,7 @@ module Dynamodb
6
6
  module Api
7
7
  class Base # :nodoc:
8
8
  include Relation
9
+ attr_accessor :last_evaluated_key
9
10
 
10
11
  def all
11
12
  raise NotImplementedError, "You must implement #{self.class}##{__method__}"
@@ -6,7 +6,19 @@ module Dynamodb
6
6
  module Api
7
7
  class Query < Base # :nodoc:
8
8
  def all
9
- Adapter.client.query(build_query)
9
+ result = Adapter.client.query(build_query)
10
+ @last_evaluated_key = result.last_evaluated_key
11
+ result
12
+ end
13
+
14
+ def next
15
+ return nil if @last_evaluated_key.blank?
16
+ result = Adapter.client.query(
17
+ build_query.merge(exclusive_start_key: @last_evaluated_key)
18
+ )
19
+ @last_evaluated_key = result.last_evaluated_key
20
+ return nil if result.count.zero?
21
+ result
10
22
  end
11
23
 
12
24
  private
@@ -6,7 +6,18 @@ module Dynamodb
6
6
  module Api
7
7
  class Scan < Base # :nodoc:
8
8
  def all
9
- Adapter.client.scan(build_query)
9
+ result = Adapter.client.scan(build_query)
10
+ @last_evaluated_key = result.last_evaluated_key
11
+ result
12
+ end
13
+
14
+ def next
15
+ return nil if @last_evaluated_key.blank?
16
+ result = Adapter.client.scan(
17
+ build_query.merge(exclusive_start_key: @last_evaluated_key)
18
+ )
19
+ @last_evaluated_key = result.last_evaluated_key
20
+ result
10
21
  end
11
22
 
12
23
  private
@@ -1,5 +1,5 @@
1
1
  module Dynamodb
2
2
  module Api
3
- VERSION = '0.7.0'.freeze
3
+ VERSION = '0.8.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamodb-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WalkerSumida
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-04 00:00:00.000000000 Z
11
+ date: 2019-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk