dynamodb_record 0.3.0 → 0.3.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/lib/dynamodb_record/associations.rb +0 -1
- data/lib/dynamodb_record/has_and_belongs_to_many_collection.rb +9 -0
- data/lib/dynamodb_record/version.rb +1 -1
- data/spec/dynamodb_record/association_spec.rb +7 -0
- data/spec/fixtures/vcr_cassettes/DynamodbRecord_Associations/_has_many/add_list.yml +311 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90c0fa26f80217dbc4d6a3f2e3fa0197a485fdcaf4bb845232c276d67c2c678e
|
4
|
+
data.tar.gz: 61d5b4ca06cfb8906902aee1ae6bafc0c4613f03edfb402447514f9877317143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea0d8a245f9f6a41c47d4cf0ef9f5ba056c31712588146b9b14f0c0886f36b487fa691c79383e93bbe34e3c87ceebdd5e8b80bb3b4f1a4ed48812944a9970985
|
7
|
+
data.tar.gz: 3c734251bd6e00ebc3ab048e702b9ed133296e0acdc09690b6da12b8c9ec7edb3f13d09a28c837d2393dc637359e228c36e334365e1a497f11890145d8db92e9
|
@@ -41,6 +41,15 @@ module DynamodbRecord
|
|
41
41
|
self.class.new(@pager.next_page(last_key), @base_object) if last_key
|
42
42
|
end
|
43
43
|
|
44
|
+
def <<(object)
|
45
|
+
table_name = @options[:table_name]
|
46
|
+
item = @options[:expression_attribute_values].transform_keys { |k| k.delete_prefix(':').to_sym }
|
47
|
+
item[:"#{@klass.to_s.downcase}_id"] = object.id
|
48
|
+
key = {table_name:, item:}
|
49
|
+
@klass.client.put_item(key)
|
50
|
+
@items << object
|
51
|
+
end
|
52
|
+
|
44
53
|
def create!(params = {})
|
45
54
|
raise "#{@base_object.class} must be saved" if @base_object.new_record
|
46
55
|
|
@@ -33,6 +33,13 @@ RSpec.describe DynamodbRecord::Associations, :vcr do
|
|
33
33
|
insurance = car.insurances.create!(name: 'fasecolda')
|
34
34
|
expect(insurance).to be_an(Insurance)
|
35
35
|
end
|
36
|
+
|
37
|
+
it 'add list' do
|
38
|
+
user = User.find!('hguzman10@gmail.com')
|
39
|
+
car = Car.find!('UVX455')
|
40
|
+
user.cars << car
|
41
|
+
expect(user.cars.count).to eq(1)
|
42
|
+
end
|
36
43
|
end
|
37
44
|
|
38
45
|
describe '#belongs_to' do
|
@@ -0,0 +1,311 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8000/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"TableName":"users","Key":{"id":{"S":"hguzman10@gmail.com"}}}'
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- ''
|
12
|
+
Content-Type:
|
13
|
+
- application/x-amz-json-1.0
|
14
|
+
X-Amz-Target:
|
15
|
+
- DynamoDB_20120810.GetItem
|
16
|
+
User-Agent:
|
17
|
+
- aws-sdk-ruby3/3.191.3 ua/2.0 api/dynamodb#1.105.0 os/macos#20 md/x86_64 lang/ruby#3.2.3
|
18
|
+
md/3.2.3 cfg/retry-mode#legacy
|
19
|
+
Host:
|
20
|
+
- localhost:8000
|
21
|
+
X-Amz-Date:
|
22
|
+
- 20240513T221654Z
|
23
|
+
X-Amz-Content-Sha256:
|
24
|
+
- 7e2248df156bd85d1c08add1aaa7b84ed6041fe96165fb6879ddbb1424663802
|
25
|
+
Authorization:
|
26
|
+
- AWS4-HMAC-SHA256 Credential=key/20240513/us-east-1/dynamodb/aws4_request,
|
27
|
+
SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
|
28
|
+
Signature=5d36d58a7b9e3a813cb337310b4e9d00c02289f75c535f244cedfb44fa11eb7a
|
29
|
+
Content-Length:
|
30
|
+
- '62'
|
31
|
+
Accept:
|
32
|
+
- "*/*"
|
33
|
+
response:
|
34
|
+
status:
|
35
|
+
code: 200
|
36
|
+
message: OK
|
37
|
+
headers:
|
38
|
+
Date:
|
39
|
+
- Mon, 13 May 2024 22:16:54 GMT
|
40
|
+
X-Amzn-Requestid:
|
41
|
+
- 711a1017-0f68-4957-9676-646de4682adb
|
42
|
+
Content-Type:
|
43
|
+
- application/x-amz-json-1.0
|
44
|
+
X-Amz-Crc32:
|
45
|
+
- '3262869781'
|
46
|
+
Content-Length:
|
47
|
+
- '157'
|
48
|
+
Server:
|
49
|
+
- Jetty(11.0.17)
|
50
|
+
body:
|
51
|
+
encoding: UTF-8
|
52
|
+
string: '{"Item":{"created_at":{"S":"2024-05-07T14:10:09-05:00"},"id":{"S":"hguzman10@gmail.com"},"balance":{"N":"0"},"updated_at":{"S":"2024-05-07T14:10:09-05:00"}}}'
|
53
|
+
recorded_at: Mon, 13 May 2024 22:16:54 GMT
|
54
|
+
- request:
|
55
|
+
method: post
|
56
|
+
uri: http://localhost:8000/
|
57
|
+
body:
|
58
|
+
encoding: UTF-8
|
59
|
+
string: '{"TableName":"cars","Key":{"id":{"S":"UVX455"}}}'
|
60
|
+
headers:
|
61
|
+
Accept-Encoding:
|
62
|
+
- ''
|
63
|
+
Content-Type:
|
64
|
+
- application/x-amz-json-1.0
|
65
|
+
X-Amz-Target:
|
66
|
+
- DynamoDB_20120810.GetItem
|
67
|
+
User-Agent:
|
68
|
+
- aws-sdk-ruby3/3.191.3 ua/2.0 api/dynamodb#1.105.0 os/macos#20 md/x86_64 lang/ruby#3.2.3
|
69
|
+
md/3.2.3 cfg/retry-mode#legacy
|
70
|
+
Host:
|
71
|
+
- localhost:8000
|
72
|
+
X-Amz-Date:
|
73
|
+
- 20240513T221654Z
|
74
|
+
X-Amz-Content-Sha256:
|
75
|
+
- 53644a2bbab903704867eb87df0fdfe6dd8cb8ac9e1dae5715033d0f636fd592
|
76
|
+
Authorization:
|
77
|
+
- AWS4-HMAC-SHA256 Credential=key/20240513/us-east-1/dynamodb/aws4_request,
|
78
|
+
SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
|
79
|
+
Signature=1a726edf9229b92796291ec3955d631f15042e898d2cdd1af503eb97c941d9fe
|
80
|
+
Content-Length:
|
81
|
+
- '48'
|
82
|
+
Accept:
|
83
|
+
- "*/*"
|
84
|
+
response:
|
85
|
+
status:
|
86
|
+
code: 200
|
87
|
+
message: OK
|
88
|
+
headers:
|
89
|
+
Date:
|
90
|
+
- Mon, 13 May 2024 22:16:54 GMT
|
91
|
+
X-Amzn-Requestid:
|
92
|
+
- dc46ebd9-194b-4de1-8a2e-7a5dff2694c0
|
93
|
+
Content-Type:
|
94
|
+
- application/x-amz-json-1.0
|
95
|
+
X-Amz-Crc32:
|
96
|
+
- '590923779'
|
97
|
+
Content-Length:
|
98
|
+
- '149'
|
99
|
+
Server:
|
100
|
+
- Jetty(11.0.17)
|
101
|
+
body:
|
102
|
+
encoding: UTF-8
|
103
|
+
string: '{"Item":{"marca":{"S":"Chvrolet"},"created_at":{"S":"2024-05-07T14:09:25-05:00"},"id":{"S":"UVX455"},"updated_at":{"S":"2024-05-07T14:09:25-05:00"}}}'
|
104
|
+
recorded_at: Mon, 13 May 2024 22:16:54 GMT
|
105
|
+
- request:
|
106
|
+
method: post
|
107
|
+
uri: http://localhost:8000/
|
108
|
+
body:
|
109
|
+
encoding: UTF-8
|
110
|
+
string: '{"TableName":"cars-users","IndexName":"cars-users-index","KeyConditionExpression":"#user_id
|
111
|
+
= :user_id","ExpressionAttributeNames":{"#user_id":"user_id"},"ExpressionAttributeValues":{":user_id":{"S":"hguzman10@gmail.com"}}}'
|
112
|
+
headers:
|
113
|
+
Accept-Encoding:
|
114
|
+
- ''
|
115
|
+
Content-Type:
|
116
|
+
- application/x-amz-json-1.0
|
117
|
+
X-Amz-Target:
|
118
|
+
- DynamoDB_20120810.Query
|
119
|
+
User-Agent:
|
120
|
+
- aws-sdk-ruby3/3.191.3 ua/2.0 api/dynamodb#1.105.0 os/macos#20 md/x86_64 lang/ruby#3.2.3
|
121
|
+
md/3.2.3 cfg/retry-mode#legacy
|
122
|
+
Host:
|
123
|
+
- localhost:8000
|
124
|
+
X-Amz-Date:
|
125
|
+
- 20240513T221654Z
|
126
|
+
X-Amz-Content-Sha256:
|
127
|
+
- 861742c900d1730c7df19f7946fa6aac3875ce336013c8c99084372c1dab4405
|
128
|
+
Authorization:
|
129
|
+
- AWS4-HMAC-SHA256 Credential=key/20240513/us-east-1/dynamodb/aws4_request,
|
130
|
+
SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
|
131
|
+
Signature=ef7169d848223d72e60f810eab3ed7d6bb1ae25372b898fd796ff3a26c4dd70e
|
132
|
+
Content-Length:
|
133
|
+
- '223'
|
134
|
+
Accept:
|
135
|
+
- "*/*"
|
136
|
+
response:
|
137
|
+
status:
|
138
|
+
code: 200
|
139
|
+
message: OK
|
140
|
+
headers:
|
141
|
+
Date:
|
142
|
+
- Mon, 13 May 2024 22:16:54 GMT
|
143
|
+
X-Amzn-Requestid:
|
144
|
+
- 86006016-6670-4107-8ad7-696d8fef517d
|
145
|
+
Content-Type:
|
146
|
+
- application/x-amz-json-1.0
|
147
|
+
X-Amz-Crc32:
|
148
|
+
- '583912891'
|
149
|
+
Content-Length:
|
150
|
+
- '39'
|
151
|
+
Server:
|
152
|
+
- Jetty(11.0.17)
|
153
|
+
body:
|
154
|
+
encoding: UTF-8
|
155
|
+
string: '{"Items":[],"Count":0,"ScannedCount":0}'
|
156
|
+
recorded_at: Mon, 13 May 2024 22:16:54 GMT
|
157
|
+
- request:
|
158
|
+
method: post
|
159
|
+
uri: http://localhost:8000/
|
160
|
+
body:
|
161
|
+
encoding: UTF-8
|
162
|
+
string: '{"TableName":"cars-users","Item":{"user_id":{"S":"hguzman10@gmail.com"},"car_id":{"S":"UVX455"}}}'
|
163
|
+
headers:
|
164
|
+
Accept-Encoding:
|
165
|
+
- ''
|
166
|
+
Content-Type:
|
167
|
+
- application/x-amz-json-1.0
|
168
|
+
X-Amz-Target:
|
169
|
+
- DynamoDB_20120810.PutItem
|
170
|
+
User-Agent:
|
171
|
+
- aws-sdk-ruby3/3.191.3 ua/2.0 api/dynamodb#1.105.0 os/macos#20 md/x86_64 lang/ruby#3.2.3
|
172
|
+
md/3.2.3 cfg/retry-mode#legacy
|
173
|
+
Host:
|
174
|
+
- localhost:8000
|
175
|
+
X-Amz-Date:
|
176
|
+
- 20240513T221654Z
|
177
|
+
X-Amz-Content-Sha256:
|
178
|
+
- e587d0399718d407bf4455227d39690706f3801ff9426a66599b446990bab89c
|
179
|
+
Authorization:
|
180
|
+
- AWS4-HMAC-SHA256 Credential=key/20240513/us-east-1/dynamodb/aws4_request,
|
181
|
+
SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
|
182
|
+
Signature=8369b75f615867caf534d5f75461ab3d3fc42580bcf244dbef28607ec667bf89
|
183
|
+
Content-Length:
|
184
|
+
- '97'
|
185
|
+
Accept:
|
186
|
+
- "*/*"
|
187
|
+
response:
|
188
|
+
status:
|
189
|
+
code: 200
|
190
|
+
message: OK
|
191
|
+
headers:
|
192
|
+
Date:
|
193
|
+
- Mon, 13 May 2024 22:16:54 GMT
|
194
|
+
X-Amzn-Requestid:
|
195
|
+
- 864c54ef-15c9-4b63-be26-77cdb6c952b6
|
196
|
+
Content-Type:
|
197
|
+
- application/x-amz-json-1.0
|
198
|
+
X-Amz-Crc32:
|
199
|
+
- '2745614147'
|
200
|
+
Content-Length:
|
201
|
+
- '2'
|
202
|
+
Server:
|
203
|
+
- Jetty(11.0.17)
|
204
|
+
body:
|
205
|
+
encoding: UTF-8
|
206
|
+
string: "{}"
|
207
|
+
recorded_at: Mon, 13 May 2024 22:16:54 GMT
|
208
|
+
- request:
|
209
|
+
method: post
|
210
|
+
uri: http://localhost:8000/
|
211
|
+
body:
|
212
|
+
encoding: UTF-8
|
213
|
+
string: '{"TableName":"cars-users","IndexName":"cars-users-index","KeyConditionExpression":"#user_id
|
214
|
+
= :user_id","ExpressionAttributeNames":{"#user_id":"user_id"},"ExpressionAttributeValues":{":user_id":{"S":"hguzman10@gmail.com"}}}'
|
215
|
+
headers:
|
216
|
+
Accept-Encoding:
|
217
|
+
- ''
|
218
|
+
Content-Type:
|
219
|
+
- application/x-amz-json-1.0
|
220
|
+
X-Amz-Target:
|
221
|
+
- DynamoDB_20120810.Query
|
222
|
+
User-Agent:
|
223
|
+
- aws-sdk-ruby3/3.191.3 ua/2.0 api/dynamodb#1.105.0 os/macos#20 md/x86_64 lang/ruby#3.2.3
|
224
|
+
md/3.2.3 cfg/retry-mode#legacy
|
225
|
+
Host:
|
226
|
+
- localhost:8000
|
227
|
+
X-Amz-Date:
|
228
|
+
- 20240513T221654Z
|
229
|
+
X-Amz-Content-Sha256:
|
230
|
+
- 861742c900d1730c7df19f7946fa6aac3875ce336013c8c99084372c1dab4405
|
231
|
+
Authorization:
|
232
|
+
- AWS4-HMAC-SHA256 Credential=key/20240513/us-east-1/dynamodb/aws4_request,
|
233
|
+
SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
|
234
|
+
Signature=ef7169d848223d72e60f810eab3ed7d6bb1ae25372b898fd796ff3a26c4dd70e
|
235
|
+
Content-Length:
|
236
|
+
- '223'
|
237
|
+
Accept:
|
238
|
+
- "*/*"
|
239
|
+
response:
|
240
|
+
status:
|
241
|
+
code: 200
|
242
|
+
message: OK
|
243
|
+
headers:
|
244
|
+
Date:
|
245
|
+
- Mon, 13 May 2024 22:16:54 GMT
|
246
|
+
X-Amzn-Requestid:
|
247
|
+
- 451f0c47-2990-42e2-a056-09def02719c8
|
248
|
+
Content-Type:
|
249
|
+
- application/x-amz-json-1.0
|
250
|
+
X-Amz-Crc32:
|
251
|
+
- '1919856377'
|
252
|
+
Content-Length:
|
253
|
+
- '102'
|
254
|
+
Server:
|
255
|
+
- Jetty(11.0.17)
|
256
|
+
body:
|
257
|
+
encoding: UTF-8
|
258
|
+
string: '{"Items":[{"user_id":{"S":"hguzman10@gmail.com"},"car_id":{"S":"UVX455"}}],"Count":1,"ScannedCount":1}'
|
259
|
+
recorded_at: Mon, 13 May 2024 22:16:54 GMT
|
260
|
+
- request:
|
261
|
+
method: post
|
262
|
+
uri: http://localhost:8000/
|
263
|
+
body:
|
264
|
+
encoding: UTF-8
|
265
|
+
string: '{"TableName":"cars","Key":{"id":{"S":"UVX455"}}}'
|
266
|
+
headers:
|
267
|
+
Accept-Encoding:
|
268
|
+
- ''
|
269
|
+
Content-Type:
|
270
|
+
- application/x-amz-json-1.0
|
271
|
+
X-Amz-Target:
|
272
|
+
- DynamoDB_20120810.GetItem
|
273
|
+
User-Agent:
|
274
|
+
- aws-sdk-ruby3/3.191.3 ua/2.0 api/dynamodb#1.105.0 os/macos#20 md/x86_64 lang/ruby#3.2.3
|
275
|
+
md/3.2.3 cfg/retry-mode#legacy
|
276
|
+
Host:
|
277
|
+
- localhost:8000
|
278
|
+
X-Amz-Date:
|
279
|
+
- 20240513T221654Z
|
280
|
+
X-Amz-Content-Sha256:
|
281
|
+
- 53644a2bbab903704867eb87df0fdfe6dd8cb8ac9e1dae5715033d0f636fd592
|
282
|
+
Authorization:
|
283
|
+
- AWS4-HMAC-SHA256 Credential=key/20240513/us-east-1/dynamodb/aws4_request,
|
284
|
+
SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
|
285
|
+
Signature=1a726edf9229b92796291ec3955d631f15042e898d2cdd1af503eb97c941d9fe
|
286
|
+
Content-Length:
|
287
|
+
- '48'
|
288
|
+
Accept:
|
289
|
+
- "*/*"
|
290
|
+
response:
|
291
|
+
status:
|
292
|
+
code: 200
|
293
|
+
message: OK
|
294
|
+
headers:
|
295
|
+
Date:
|
296
|
+
- Mon, 13 May 2024 22:16:54 GMT
|
297
|
+
X-Amzn-Requestid:
|
298
|
+
- 9d01d52e-6a41-48a4-99ed-fda216f6dd30
|
299
|
+
Content-Type:
|
300
|
+
- application/x-amz-json-1.0
|
301
|
+
X-Amz-Crc32:
|
302
|
+
- '590923779'
|
303
|
+
Content-Length:
|
304
|
+
- '149'
|
305
|
+
Server:
|
306
|
+
- Jetty(11.0.17)
|
307
|
+
body:
|
308
|
+
encoding: UTF-8
|
309
|
+
string: '{"Item":{"marca":{"S":"Chvrolet"},"created_at":{"S":"2024-05-07T14:09:25-05:00"},"id":{"S":"UVX455"},"updated_at":{"S":"2024-05-07T14:09:25-05:00"}}}'
|
310
|
+
recorded_at: Mon, 13 May 2024 22:16:54 GMT
|
311
|
+
recorded_with: VCR 6.2.0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamodb_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henry Guzman
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- spec/dynamodb_record/persistence_spec.rb
|
202
202
|
- spec/dynamodb_record/query_spec.rb
|
203
203
|
- spec/fixtures/vcr_cassettes/DynamodbRecord_Associations/_belongs_to/get_object.yml
|
204
|
+
- spec/fixtures/vcr_cassettes/DynamodbRecord_Associations/_has_many/add_list.yml
|
204
205
|
- spec/fixtures/vcr_cassettes/DynamodbRecord_Associations/_has_many/create_item.yml
|
205
206
|
- spec/fixtures/vcr_cassettes/DynamodbRecord_Associations/_has_many/get_collection.yml
|
206
207
|
- spec/fixtures/vcr_cassettes/DynamodbRecord_Associations/has_and_belongs_to_many.yml
|