dynamini 2.10.0 → 2.10.1
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 +4 -4
- data/README.md +2 -0
- data/dynamini.gemspec +1 -1
- data/lib/dynamini/batch_operations.rb +5 -3
- data/spec/dynamini/batch_operations_spec.rb +25 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7666f36d72a5a8cd120410d8d1f915d79ca61d50
|
4
|
+
data.tar.gz: cb3c42f63ecb17bbfc877f534829ee8b915e3fb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdc3861dca2bb1a7c2253b188e70023bffbc90cfc12c8c35f5fadc8b7bf1a382ed4e9619051526e321f28e82fbed062f9d14b74d3f9eb7c6c02d73466289f751
|
7
|
+
data.tar.gz: 090851dfcd7df23511dc98800d3946de5e6133520128953c81980fa545da3f256927ef88a39c491bdca7baebd5e236c4c4cecfdcf47639b415dda9940d93d89a
|
data/README.md
CHANGED
@@ -134,6 +134,8 @@ Default values aren't actually written to the database when saving your instance
|
|
134
134
|
|
135
135
|
The auto-generated fields updated_at and created_at are intrinsically handled as :time.
|
136
136
|
|
137
|
+
If you want to see all your attributes at once, with type conversions applied (e.g for serialization as JSON), call :handled_attributes. The :attributes method, conversely, will show you the real values as written to DynamoDB.
|
138
|
+
|
137
139
|
## Enumerable Attributes
|
138
140
|
You can save arrays and sets to your Dynamini model. Optionally, you can have Dynamini perform type conversion on each element of your enumerable. Here's how it works:
|
139
141
|
|
data/dynamini.gemspec
CHANGED
@@ -28,9 +28,11 @@ module Dynamini
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def batch_delete(ids)
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
deletes = ids.map{ |id| { delete_request: { key: { hash_key => id } } } }
|
32
|
+
|
33
|
+
deletes.each_slice(25) do |slice|
|
34
|
+
client.batch_write_item(request_items: { table_name => slice })
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
def scan(options = {})
|
@@ -88,13 +88,12 @@ describe Dynamini::BatchOperations do
|
|
88
88
|
|
89
89
|
context 'when requesting over 100 items' do
|
90
90
|
let(:ids) do
|
91
|
-
i
|
91
|
+
i = *(1..101)
|
92
92
|
i.map(&:to_s)
|
93
93
|
end
|
94
94
|
|
95
95
|
before do
|
96
|
-
i
|
97
|
-
i.each { |id| Dynamini::Base.create(id: id.to_s) }
|
96
|
+
51.times { |i| Dynamini::Base.create(id: (i + 1).to_s) }
|
98
97
|
end
|
99
98
|
|
100
99
|
it 'should call dynamo once for each 100 items' do
|
@@ -119,11 +118,29 @@ describe Dynamini::BatchOperations do
|
|
119
118
|
Dynamini::Base.create(id: '7890')
|
120
119
|
end
|
121
120
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
121
|
+
context 'when deleting the max length or under' do
|
122
|
+
it 'should delete all items in collection to the database' do
|
123
|
+
subject.batch_delete(ids)
|
124
|
+
expect{ Dynamini::Base.find('4321') }.to raise_error(Dynamini::RecordNotFound)
|
125
|
+
expect{ Dynamini::Base.find('4567') }.to raise_error(Dynamini::RecordNotFound)
|
126
|
+
expect{ Dynamini::Base.find('7890') }.to raise_error(Dynamini::RecordNotFound)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'when deleting more than the max length' do
|
131
|
+
let (:ids) do
|
132
|
+
[
|
133
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4321, 17, 18, 19, 20, 4567, 22, 23, 24, 25,
|
134
|
+
26, 7890
|
135
|
+
].map{ |id| id.to_s }
|
136
|
+
end
|
137
|
+
it 'invokes the client with each slice' do
|
138
|
+
expect(Dynamini::Base.client).to receive(:batch_write_item).twice.and_call_original
|
139
|
+
subject.batch_delete(ids)
|
140
|
+
expect{ Dynamini::Base.find('4321') }.to raise_error(Dynamini::RecordNotFound)
|
141
|
+
expect{ Dynamini::Base.find('4567') }.to raise_error(Dynamini::RecordNotFound)
|
142
|
+
expect{ Dynamini::Base.find('7890') }.to raise_error(Dynamini::RecordNotFound)
|
143
|
+
end
|
127
144
|
end
|
128
145
|
end
|
129
146
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamini
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Ward
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2017-09-
|
18
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activemodel
|