dynamodb_record 0.1.0 → 0.2.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: f277db1e3a81f575346f3f0b802259a5bb52a0258b7a63d5e6e674c5c93b8e5c
4
- data.tar.gz: d6830c149b35e6d0cd8a38dcb5f1ed4b3c75ec499079450c45f5a038610a0509
3
+ metadata.gz: 49693eaf2b663b1061fd4c1bb498fa8c1bc6f2d49ec3a02b5a85fe7fd5cd3161
4
+ data.tar.gz: a52d2fdfddbe64f06f50d60e4076c57eae6093b6615f88743af1d557bb73b8eb
5
5
  SHA512:
6
- metadata.gz: a02a723d2213b545a9ab6d5e7e9dd22e514c2868bc62711df3618509d7a6b09011885d626393fa138357db88efbac19bcd46dfcd1d5820e5d5a51f0920f2890b
7
- data.tar.gz: 288cfa625378466e04ecba3f22e5e50676f54a732e1b718e81f99f181088ce2786e291ddfd8b6af51a408389dcf53278b7229af081f48ef3731ae7aca2469934
6
+ metadata.gz: 71c72c3eac3ce2212c19894745d03087c0466c1fa2cfc7bc29bf23d123f7204f7cc7eae96d37c199180786ea31fe5248e2fbceba294ff57acbd8d53d44aa8ac3
7
+ data.tar.gz: '082aa5bb291c03ad4963a101e32efa070c10b403e1d5ca55f172ab7c60a26a7ceb5556d527e35e2bea04bf412762244accddc801d082903e08808dcda7f294a2'
@@ -5,9 +5,9 @@ module DynamodbRecord
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- class_attribute :attributes, :hash_key, instance_writer: true
8
+ class_attribute :attributes, instance_writer: true
9
9
  self.attributes = {}
10
- self.hash_key = nil
10
+ # self.hash_key = nil
11
11
 
12
12
  # default hash key
13
13
  field :id, :string
@@ -21,7 +21,8 @@ module DynamodbRecord
21
21
  # Add attributes
22
22
  attributes.merge!(name => { type:, options: opts })
23
23
 
24
- self.hash_key = name if opts[:hash_key]
24
+ # self.hash_key = name if opts[:hash_key]
25
+ # self.range_key = name if opts[:range_key]
25
26
 
26
27
  # Generate methods to field
27
28
  define_method("#{named}=") { |value| write_attribute(named, value) }
@@ -77,28 +78,21 @@ module DynamodbRecord
77
78
  def unload(attrs)
78
79
  {}.tap do |hash|
79
80
  attrs.each do |key, value|
80
- if attributes[key.to_sym][:options][:hash_key]
81
- # puts "KEY #{key} | #{dump_field(value, self.attributes[key.to_sym])}"
82
- hash[:pk] = dump_field(value, attributes[key.to_sym])
83
- end
81
+ # if attributes[key.to_sym][:options][:hash_key]
82
+ # hash[:pk] = dump_field(value, attributes[key.to_sym])
83
+ # end
84
84
 
85
- # puts "KEY #{key}|#{value}|#{self.attributes[key.to_sym]}"
86
85
  hash[key] = dump_field(value, attributes[key.to_sym])
87
- # puts "HASH: #{hash}"
88
86
  end
89
87
  end
90
88
  end
91
89
 
92
90
  def hash_key
93
- :id # default hash key
91
+ @hash_key = attributes.select { |_k,v| v[:options][:hash_key] }.keys.first || :id
94
92
  end
95
93
 
96
94
  def range_key
97
- @range_key ||= begin
98
- attributes.select { |_k, v| v[:options][:range_key] }.keys.first
99
- rescue StandardError
100
- nil
101
- end
95
+ @range_key ||= attributes.select { |_k,v| v[:options][:range_key] }.keys.first rescue nil
102
96
  end
103
97
 
104
98
  def secondary_indexes
@@ -12,9 +12,10 @@ module DynamodbRecord
12
12
  end
13
13
 
14
14
  def find!(id, range_key = nil)
15
- key = { 'id' => id }
16
-
15
+ key = {}
16
+ key[hash_key] = id
17
17
  key[self.range_key] = range_key if self.range_key
18
+
18
19
  response = client.get_item(
19
20
  table_name:,
20
21
  key:
@@ -117,13 +117,22 @@ module DynamodbRecord
117
117
  end
118
118
 
119
119
  options.merge!(item: self.class.unload(attributes))
120
+ # puts options
120
121
  self.class.client.put_item(options)
121
122
  @new_record = false
122
123
  end
123
124
 
124
125
  def destroy
125
126
  options = self.class.default_options
126
- key = { 'pk' => pk, 'sk' => sk }
127
+ hash_key = self.class.hash_key
128
+ range_key = self.class.range_key
129
+ key = {}
130
+ key[hash_key] = self.class.dump_field(self.read_attribute(hash_key), self.class.attributes[hash_key])
131
+
132
+ if range_key.present?
133
+ key[range_key] = self.class.dump_field(self.read_attribute(range_key), self.class.attributes[range_key])
134
+ end
135
+
127
136
  self.class.client.delete_item(options.merge(key:))
128
137
  end
129
138
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamodbRecord
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Authorization
4
+ include DynamodbRecord::Document
5
+
6
+ field :user_id, :string, hash_key: true
7
+ field :service_id, :string, range_key: true
8
+
9
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe DynamodbRecord::Persistence, :vcr do
4
+
5
+ it 'saves record' do
6
+ user = User.new(id: 'hguzman10@gmail.com')
7
+ user.save
8
+ expect(user.new_record).to be_falsy
9
+ expect(user.id).to eq('hguzman10@gmail.com')
10
+ end
11
+
12
+ it 'does not overwrite existing record' do
13
+ user = User.new(id: 'hguzman10@gmail.com', balance: 100)
14
+ expect(user.save).to be_falsy
15
+
16
+ user = User.find('hguzman10@gmail.com')
17
+ expect(user.balance).to_not eq(100)
18
+ end
19
+
20
+ it 'updates record' do
21
+ user = User.find('hguzman10@gmail.com')
22
+ user.balance = 60
23
+ user.save
24
+ user = User.find('hguzman10@gmail.com')
25
+ expect(user.balance).to eq(60)
26
+ end
27
+
28
+ describe '#destroy' do
29
+ context 'when no range key' do
30
+ it 'destroys record' do
31
+ user = User.find('hguzman10@gmail.com')
32
+ user.destroy
33
+ user = User.find('hguzman10@gmail.com')
34
+ expect(user).to be_nil
35
+ end
36
+ end
37
+
38
+ context 'when there is range key' do
39
+ it 'destroys record' do
40
+ authorization = Authorization.find!('hguzman10@gmail.com', '1')
41
+ authorization.destroy
42
+ authorization = Authorization.find('hguzman10@gmail.com', '1')
43
+ expect(authorization).to be_nil
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,156 @@
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
+ - 20240502T003644Z
23
+ X-Amz-Content-Sha256:
24
+ - 7e2248df156bd85d1c08add1aaa7b84ed6041fe96165fb6879ddbb1424663802
25
+ Authorization:
26
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
27
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
28
+ Signature=94cc004156fe51a634d7bc47199d168f53887124cadf4eaf91af8970cd7e0751
29
+ Content-Length:
30
+ - '62'
31
+ Accept:
32
+ - "*/*"
33
+ response:
34
+ status:
35
+ code: 200
36
+ message: OK
37
+ headers:
38
+ Date:
39
+ - Thu, 02 May 2024 00:36:44 GMT
40
+ X-Amzn-Requestid:
41
+ - 7bae8e3b-f05f-4711-809b-13029004a792
42
+ Content-Type:
43
+ - application/x-amz-json-1.0
44
+ X-Amz-Crc32:
45
+ - '3547979423'
46
+ Content-Length:
47
+ - '158'
48
+ Server:
49
+ - Jetty(11.0.17)
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"Item":{"created_at":{"S":"2024-05-01T19:36:43-05:00"},"id":{"S":"hguzman10@gmail.com"},"balance":{"N":"60"},"updated_at":{"S":"2024-05-01T19:36:43-05:00"}}}'
53
+ recorded_at: Thu, 02 May 2024 00:36:44 GMT
54
+ - request:
55
+ method: post
56
+ uri: http://localhost:8000/
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"TableName":"users","Key":{"id":{"S":"hguzman10@gmail.com"}}}'
60
+ headers:
61
+ Accept-Encoding:
62
+ - ''
63
+ Content-Type:
64
+ - application/x-amz-json-1.0
65
+ X-Amz-Target:
66
+ - DynamoDB_20120810.DeleteItem
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
+ - 20240502T003644Z
74
+ X-Amz-Content-Sha256:
75
+ - 7e2248df156bd85d1c08add1aaa7b84ed6041fe96165fb6879ddbb1424663802
76
+ Authorization:
77
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
78
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
79
+ Signature=961736055c2544461f423b2aeebefa85e0c7c0f3e5cbf1f6a3734be3c29ad1c2
80
+ Content-Length:
81
+ - '62'
82
+ Accept:
83
+ - "*/*"
84
+ response:
85
+ status:
86
+ code: 200
87
+ message: OK
88
+ headers:
89
+ Date:
90
+ - Thu, 02 May 2024 00:36:44 GMT
91
+ X-Amzn-Requestid:
92
+ - d9042a14-8c30-46a1-9ae1-3f352dff03ab
93
+ Content-Type:
94
+ - application/x-amz-json-1.0
95
+ X-Amz-Crc32:
96
+ - '2745614147'
97
+ Content-Length:
98
+ - '2'
99
+ Server:
100
+ - Jetty(11.0.17)
101
+ body:
102
+ encoding: UTF-8
103
+ string: "{}"
104
+ recorded_at: Thu, 02 May 2024 00:36:44 GMT
105
+ - request:
106
+ method: post
107
+ uri: http://localhost:8000/
108
+ body:
109
+ encoding: UTF-8
110
+ string: '{"TableName":"users","Key":{"id":{"S":"hguzman10@gmail.com"}}}'
111
+ headers:
112
+ Accept-Encoding:
113
+ - ''
114
+ Content-Type:
115
+ - application/x-amz-json-1.0
116
+ X-Amz-Target:
117
+ - DynamoDB_20120810.GetItem
118
+ User-Agent:
119
+ - 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
120
+ md/3.2.3 cfg/retry-mode#legacy
121
+ Host:
122
+ - localhost:8000
123
+ X-Amz-Date:
124
+ - 20240502T003644Z
125
+ X-Amz-Content-Sha256:
126
+ - 7e2248df156bd85d1c08add1aaa7b84ed6041fe96165fb6879ddbb1424663802
127
+ Authorization:
128
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
129
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
130
+ Signature=94cc004156fe51a634d7bc47199d168f53887124cadf4eaf91af8970cd7e0751
131
+ Content-Length:
132
+ - '62'
133
+ Accept:
134
+ - "*/*"
135
+ response:
136
+ status:
137
+ code: 200
138
+ message: OK
139
+ headers:
140
+ Date:
141
+ - Thu, 02 May 2024 00:36:44 GMT
142
+ X-Amzn-Requestid:
143
+ - d8e23373-1aee-4727-839e-fed721efdc77
144
+ Content-Type:
145
+ - application/x-amz-json-1.0
146
+ X-Amz-Crc32:
147
+ - '2745614147'
148
+ Content-Length:
149
+ - '2'
150
+ Server:
151
+ - Jetty(11.0.17)
152
+ body:
153
+ encoding: UTF-8
154
+ string: "{}"
155
+ recorded_at: Thu, 02 May 2024 00:36:44 GMT
156
+ recorded_with: VCR 6.2.0
@@ -0,0 +1,156 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:8000/
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"TableName":"authorizations","Key":{"user_id":{"S":"hguzman10@gmail.com"},"service_id":{"S":"1"}}}'
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
+ - 20240502T001527Z
23
+ X-Amz-Content-Sha256:
24
+ - 904e20d3b7d573308942eb45e345aed8a0d28331d9087eb40a19412554c62258
25
+ Authorization:
26
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
27
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
28
+ Signature=a27d2463aed9f0c4f86c0db83f3d99d3e15b3482533e4d3c4430fda0de0e1312
29
+ Content-Length:
30
+ - '99'
31
+ Accept:
32
+ - "*/*"
33
+ response:
34
+ status:
35
+ code: 200
36
+ message: OK
37
+ headers:
38
+ Date:
39
+ - Thu, 02 May 2024 00:15:27 GMT
40
+ X-Amzn-Requestid:
41
+ - b0ad8800-588e-433b-b314-539bd7598d91
42
+ Content-Type:
43
+ - application/x-amz-json-1.0
44
+ X-Amz-Crc32:
45
+ - '2017503589'
46
+ Content-Length:
47
+ - '71'
48
+ Server:
49
+ - Jetty(11.0.17)
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"Item":{"user_id":{"S":"hguzman10@gmail.com"},"service_id":{"S":"1"}}}'
53
+ recorded_at: Thu, 02 May 2024 00:15:27 GMT
54
+ - request:
55
+ method: post
56
+ uri: http://localhost:8000/
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"TableName":"authorizations","Key":{"user_id":{"S":"hguzman10@gmail.com"},"service_id":{"S":"1"}}}'
60
+ headers:
61
+ Accept-Encoding:
62
+ - ''
63
+ Content-Type:
64
+ - application/x-amz-json-1.0
65
+ X-Amz-Target:
66
+ - DynamoDB_20120810.DeleteItem
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
+ - 20240502T001527Z
74
+ X-Amz-Content-Sha256:
75
+ - 904e20d3b7d573308942eb45e345aed8a0d28331d9087eb40a19412554c62258
76
+ Authorization:
77
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
78
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
79
+ Signature=8b44cb46b1680b538fe9455591b2a9cc8d28fd93ac35a154afed681e468130fd
80
+ Content-Length:
81
+ - '99'
82
+ Accept:
83
+ - "*/*"
84
+ response:
85
+ status:
86
+ code: 200
87
+ message: OK
88
+ headers:
89
+ Date:
90
+ - Thu, 02 May 2024 00:15:27 GMT
91
+ X-Amzn-Requestid:
92
+ - '016797fb-ab5f-4574-88f3-7e826cac42df'
93
+ Content-Type:
94
+ - application/x-amz-json-1.0
95
+ X-Amz-Crc32:
96
+ - '2745614147'
97
+ Content-Length:
98
+ - '2'
99
+ Server:
100
+ - Jetty(11.0.17)
101
+ body:
102
+ encoding: UTF-8
103
+ string: "{}"
104
+ recorded_at: Thu, 02 May 2024 00:15:27 GMT
105
+ - request:
106
+ method: post
107
+ uri: http://localhost:8000/
108
+ body:
109
+ encoding: UTF-8
110
+ string: '{"TableName":"authorizations","Key":{"user_id":{"S":"hguzman10@gmail.com"},"service_id":{"S":"1"}}}'
111
+ headers:
112
+ Accept-Encoding:
113
+ - ''
114
+ Content-Type:
115
+ - application/x-amz-json-1.0
116
+ X-Amz-Target:
117
+ - DynamoDB_20120810.GetItem
118
+ User-Agent:
119
+ - 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
120
+ md/3.2.3 cfg/retry-mode#legacy
121
+ Host:
122
+ - localhost:8000
123
+ X-Amz-Date:
124
+ - 20240502T001527Z
125
+ X-Amz-Content-Sha256:
126
+ - 904e20d3b7d573308942eb45e345aed8a0d28331d9087eb40a19412554c62258
127
+ Authorization:
128
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
129
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
130
+ Signature=a27d2463aed9f0c4f86c0db83f3d99d3e15b3482533e4d3c4430fda0de0e1312
131
+ Content-Length:
132
+ - '99'
133
+ Accept:
134
+ - "*/*"
135
+ response:
136
+ status:
137
+ code: 200
138
+ message: OK
139
+ headers:
140
+ Date:
141
+ - Thu, 02 May 2024 00:15:27 GMT
142
+ X-Amzn-Requestid:
143
+ - f7ad1c7f-8266-4da1-8355-7200d06d4f97
144
+ Content-Type:
145
+ - application/x-amz-json-1.0
146
+ X-Amz-Crc32:
147
+ - '2745614147'
148
+ Content-Length:
149
+ - '2'
150
+ Server:
151
+ - Jetty(11.0.17)
152
+ body:
153
+ encoding: UTF-8
154
+ string: "{}"
155
+ recorded_at: Thu, 02 May 2024 00:15:27 GMT
156
+ recorded_with: VCR 6.2.0
@@ -0,0 +1,104 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:8000/
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"TableName":"users","ConditionExpression":"id <> :s","ExpressionAttributeValues":{":s":{"S":"hguzman10@gmail.com"}},"Item":{"balance":{"N":"100"},"id":{"S":"hguzman10@gmail.com"},"created_at":{"S":"2024-05-01T19:36:43-05:00"},"updated_at":{"S":"2024-05-01T19:36:43-05:00"}}}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - ''
12
+ Content-Type:
13
+ - application/x-amz-json-1.0
14
+ X-Amz-Target:
15
+ - DynamoDB_20120810.PutItem
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
+ - 20240502T003643Z
23
+ X-Amz-Content-Sha256:
24
+ - 6ba894a3f3d7e47c03481928aa642e796e2e8b11c8f7a85324b66918fabe67fb
25
+ Authorization:
26
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
27
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
28
+ Signature=ecc9987a544fe53aa846cf53473b4438e6c7ca89b3db1d77cc163d28965c0d34
29
+ Content-Length:
30
+ - '275'
31
+ Accept:
32
+ - "*/*"
33
+ response:
34
+ status:
35
+ code: 400
36
+ message: Bad Request
37
+ headers:
38
+ Date:
39
+ - Thu, 02 May 2024 00:36:43 GMT
40
+ X-Amzn-Requestid:
41
+ - abb2b185-4ffa-4b9e-b7b9-73a56fe18b8f
42
+ Content-Type:
43
+ - application/x-amz-json-1.0
44
+ Content-Length:
45
+ - '120'
46
+ Server:
47
+ - Jetty(11.0.17)
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"__type":"com.amazonaws.dynamodb.v20120810#ConditionalCheckFailedException","Message":"The
51
+ conditional request failed"}'
52
+ recorded_at: Thu, 02 May 2024 00:36:43 GMT
53
+ - request:
54
+ method: post
55
+ uri: http://localhost:8000/
56
+ body:
57
+ encoding: UTF-8
58
+ string: '{"TableName":"users","Key":{"id":{"S":"hguzman10@gmail.com"}}}'
59
+ headers:
60
+ Accept-Encoding:
61
+ - ''
62
+ Content-Type:
63
+ - application/x-amz-json-1.0
64
+ X-Amz-Target:
65
+ - DynamoDB_20120810.GetItem
66
+ User-Agent:
67
+ - 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
68
+ md/3.2.3 cfg/retry-mode#legacy
69
+ Host:
70
+ - localhost:8000
71
+ X-Amz-Date:
72
+ - 20240502T003643Z
73
+ X-Amz-Content-Sha256:
74
+ - 7e2248df156bd85d1c08add1aaa7b84ed6041fe96165fb6879ddbb1424663802
75
+ Authorization:
76
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
77
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
78
+ Signature=e61f5c53269131bf5f985bfbe1385615456dcedad7ae5fce0fe1ce0a4e854705
79
+ Content-Length:
80
+ - '62'
81
+ Accept:
82
+ - "*/*"
83
+ response:
84
+ status:
85
+ code: 200
86
+ message: OK
87
+ headers:
88
+ Date:
89
+ - Thu, 02 May 2024 00:36:43 GMT
90
+ X-Amzn-Requestid:
91
+ - 05b8fc5c-d523-4191-bac0-d31621e3857c
92
+ Content-Type:
93
+ - application/x-amz-json-1.0
94
+ X-Amz-Crc32:
95
+ - '1030740054'
96
+ Content-Length:
97
+ - '157'
98
+ Server:
99
+ - Jetty(11.0.17)
100
+ body:
101
+ encoding: UTF-8
102
+ string: '{"Item":{"created_at":{"S":"2024-05-01T19:36:43-05:00"},"id":{"S":"hguzman10@gmail.com"},"balance":{"N":"0"},"updated_at":{"S":"2024-05-01T19:36:43-05:00"}}}'
103
+ recorded_at: Thu, 02 May 2024 00:36:43 GMT
104
+ recorded_with: VCR 6.2.0
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:8000/
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"TableName":"users","ConditionExpression":"id <> :s","ExpressionAttributeValues":{":s":{"S":"hguzman10@gmail.com"}},"Item":{"balance":{"N":"0"},"id":{"S":"hguzman10@gmail.com"},"created_at":{"S":"2024-05-01T19:36:43-05:00"},"updated_at":{"S":"2024-05-01T19:36:43-05:00"}}}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - ''
12
+ Content-Type:
13
+ - application/x-amz-json-1.0
14
+ X-Amz-Target:
15
+ - DynamoDB_20120810.PutItem
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
+ - 20240502T003643Z
23
+ X-Amz-Content-Sha256:
24
+ - a6814143d7653f7f2d9abb6d2cf7c7b12ba0b621092b359971c44569d1bc2778
25
+ Authorization:
26
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
27
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
28
+ Signature=28275abed7119af00065965863f46b56a8f8db07e4ac789d86411f1f2c44155c
29
+ Content-Length:
30
+ - '273'
31
+ Accept:
32
+ - "*/*"
33
+ response:
34
+ status:
35
+ code: 200
36
+ message: OK
37
+ headers:
38
+ Date:
39
+ - Thu, 02 May 2024 00:36:43 GMT
40
+ X-Amzn-Requestid:
41
+ - c07e3cbf-e2be-4eb3-afb6-dad85bcdbe3f
42
+ Content-Type:
43
+ - application/x-amz-json-1.0
44
+ X-Amz-Crc32:
45
+ - '2745614147'
46
+ Content-Length:
47
+ - '2'
48
+ Server:
49
+ - Jetty(11.0.17)
50
+ body:
51
+ encoding: UTF-8
52
+ string: "{}"
53
+ recorded_at: Thu, 02 May 2024 00:36:43 GMT
54
+ recorded_with: VCR 6.2.0
@@ -0,0 +1,156 @@
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
+ - 20240502T003643Z
23
+ X-Amz-Content-Sha256:
24
+ - 7e2248df156bd85d1c08add1aaa7b84ed6041fe96165fb6879ddbb1424663802
25
+ Authorization:
26
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
27
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
28
+ Signature=e61f5c53269131bf5f985bfbe1385615456dcedad7ae5fce0fe1ce0a4e854705
29
+ Content-Length:
30
+ - '62'
31
+ Accept:
32
+ - "*/*"
33
+ response:
34
+ status:
35
+ code: 200
36
+ message: OK
37
+ headers:
38
+ Date:
39
+ - Thu, 02 May 2024 00:36:43 GMT
40
+ X-Amzn-Requestid:
41
+ - ecb90d9f-4d44-400e-82f0-20214b690e4c
42
+ Content-Type:
43
+ - application/x-amz-json-1.0
44
+ X-Amz-Crc32:
45
+ - '1030740054'
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-01T19:36:43-05:00"},"id":{"S":"hguzman10@gmail.com"},"balance":{"N":"0"},"updated_at":{"S":"2024-05-01T19:36:43-05:00"}}}'
53
+ recorded_at: Thu, 02 May 2024 00:36:43 GMT
54
+ - request:
55
+ method: post
56
+ uri: http://localhost:8000/
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"TableName":"users","Item":{"balance":{"N":"60"},"created_at":{"S":"2024-05-01T19:36:43-05:00"},"id":{"S":"hguzman10@gmail.com"},"updated_at":{"S":"2024-05-01T19:36:43-05:00"}}}'
60
+ headers:
61
+ Accept-Encoding:
62
+ - ''
63
+ Content-Type:
64
+ - application/x-amz-json-1.0
65
+ X-Amz-Target:
66
+ - DynamoDB_20120810.PutItem
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
+ - 20240502T003643Z
74
+ X-Amz-Content-Sha256:
75
+ - bce2e7f8fe409b9ee303c60086f066bdcd1046f72262b55b295dec463d74e106
76
+ Authorization:
77
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
78
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
79
+ Signature=66196ff2d65820f4c27935312b8b6a4cbe87288ffceb59025123e77b342f37cf
80
+ Content-Length:
81
+ - '178'
82
+ Accept:
83
+ - "*/*"
84
+ response:
85
+ status:
86
+ code: 200
87
+ message: OK
88
+ headers:
89
+ Date:
90
+ - Thu, 02 May 2024 00:36:43 GMT
91
+ X-Amzn-Requestid:
92
+ - 56298a7a-ad76-45f8-855f-883653ec8f06
93
+ Content-Type:
94
+ - application/x-amz-json-1.0
95
+ X-Amz-Crc32:
96
+ - '2745614147'
97
+ Content-Length:
98
+ - '2'
99
+ Server:
100
+ - Jetty(11.0.17)
101
+ body:
102
+ encoding: UTF-8
103
+ string: "{}"
104
+ recorded_at: Thu, 02 May 2024 00:36:43 GMT
105
+ - request:
106
+ method: post
107
+ uri: http://localhost:8000/
108
+ body:
109
+ encoding: UTF-8
110
+ string: '{"TableName":"users","Key":{"id":{"S":"hguzman10@gmail.com"}}}'
111
+ headers:
112
+ Accept-Encoding:
113
+ - ''
114
+ Content-Type:
115
+ - application/x-amz-json-1.0
116
+ X-Amz-Target:
117
+ - DynamoDB_20120810.GetItem
118
+ User-Agent:
119
+ - 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
120
+ md/3.2.3 cfg/retry-mode#legacy
121
+ Host:
122
+ - localhost:8000
123
+ X-Amz-Date:
124
+ - 20240502T003643Z
125
+ X-Amz-Content-Sha256:
126
+ - 7e2248df156bd85d1c08add1aaa7b84ed6041fe96165fb6879ddbb1424663802
127
+ Authorization:
128
+ - AWS4-HMAC-SHA256 Credential=AKIAV3OBKSDM5UO5PK5A/20240502/us-east-1/dynamodb/aws4_request,
129
+ SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target,
130
+ Signature=e61f5c53269131bf5f985bfbe1385615456dcedad7ae5fce0fe1ce0a4e854705
131
+ Content-Length:
132
+ - '62'
133
+ Accept:
134
+ - "*/*"
135
+ response:
136
+ status:
137
+ code: 200
138
+ message: OK
139
+ headers:
140
+ Date:
141
+ - Thu, 02 May 2024 00:36:43 GMT
142
+ X-Amzn-Requestid:
143
+ - 8ca63cc3-80f7-4e9e-9fa1-f891ed851802
144
+ Content-Type:
145
+ - application/x-amz-json-1.0
146
+ X-Amz-Crc32:
147
+ - '3547979423'
148
+ Content-Length:
149
+ - '158'
150
+ Server:
151
+ - Jetty(11.0.17)
152
+ body:
153
+ encoding: UTF-8
154
+ string: '{"Item":{"created_at":{"S":"2024-05-01T19:36:43-05:00"},"id":{"S":"hguzman10@gmail.com"},"balance":{"N":"60"},"updated_at":{"S":"2024-05-01T19:36:43-05:00"}}}'
155
+ recorded_at: Thu, 02 May 2024 00:36:43 GMT
156
+ 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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Guzman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-04-26 00:00:00.000000000 Z
12
+ date: 2024-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -181,14 +181,21 @@ files:
181
181
  - lib/dynamodb_record/persistence.rb
182
182
  - lib/dynamodb_record/query.rb
183
183
  - lib/dynamodb_record/version.rb
184
+ - spec/app/models/authorization.rb
184
185
  - spec/app/models/person.rb
185
186
  - spec/app/models/user.rb
186
187
  - spec/dynamodb_record/document_spec.rb
187
188
  - spec/dynamodb_record/fields_spec.rb
188
189
  - spec/dynamodb_record/finders_spec.rb
190
+ - spec/dynamodb_record/persistence_spec.rb
189
191
  - spec/fixtures/vcr_cassettes/DynamodbRecord_Document/initializes_from_database.yml
190
192
  - spec/fixtures/vcr_cassettes/DynamodbRecord_Fields/_find/finds_record.yml
191
193
  - spec/fixtures/vcr_cassettes/DynamodbRecord_Fields/_find/when_record_doesn_t_exists/returns_empty_object.yml
194
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/_destroy/when_no_range_key/destroys_record.yml
195
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/_destroy/when_there_is_range_key/destroys_record.yml
196
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/does_not_overwrite_existing_record.yml
197
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/saves_record.yml
198
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/updates_record.yml
192
199
  - spec/spec_helper.rb
193
200
  homepage: https://github.com/CarsOk/dynamodb-record
194
201
  licenses:
@@ -214,12 +221,19 @@ signing_key:
214
221
  specification_version: 4
215
222
  summary: A simple DynamoDB ORM
216
223
  test_files:
224
+ - spec/app/models/authorization.rb
217
225
  - spec/app/models/person.rb
218
226
  - spec/app/models/user.rb
219
227
  - spec/dynamodb_record/document_spec.rb
220
228
  - spec/dynamodb_record/fields_spec.rb
221
229
  - spec/dynamodb_record/finders_spec.rb
230
+ - spec/dynamodb_record/persistence_spec.rb
222
231
  - spec/fixtures/vcr_cassettes/DynamodbRecord_Document/initializes_from_database.yml
223
232
  - spec/fixtures/vcr_cassettes/DynamodbRecord_Fields/_find/finds_record.yml
224
233
  - spec/fixtures/vcr_cassettes/DynamodbRecord_Fields/_find/when_record_doesn_t_exists/returns_empty_object.yml
234
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/_destroy/when_no_range_key/destroys_record.yml
235
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/_destroy/when_there_is_range_key/destroys_record.yml
236
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/does_not_overwrite_existing_record.yml
237
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/saves_record.yml
238
+ - spec/fixtures/vcr_cassettes/DynamodbRecord_Persistence/updates_record.yml
225
239
  - spec/spec_helper.rb