dynamodb_helpers 0.2.0 → 0.3.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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +8 -6
- data/README.md +10 -3
- data/dynamodb_helpers.gemspec +1 -1
- data/lib/dynamodb_helpers.rb +10 -3
- data/lib/dynamodb_helpers/version.rb +1 -1
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 799b8b0b74b057cd60136e9edff897f0d1ef2689
|
4
|
+
data.tar.gz: 57a56363cf62f42625b1456965c0dc3dd2757275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e55d62e619c0e7282d3195d3e4790116147763e66638abb3d3cca8c2cbd16b60eea3ea48955d4f0cefccaa31bb627bd94658f26fc8e49f45ccb4151e9fdf1d38
|
7
|
+
data.tar.gz: ffedaaca92f9f7dc83f6a0960ca422ae29638144a290079ed6262e8ed6053faf301d2ff96aa86d75a95d9b08809b1ade5a79d48d5b4f1fc0fd750931005fe271
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dynamodb_helpers (0.
|
4
|
+
dynamodb_helpers (0.3.0)
|
5
5
|
aws-sdk-dynamodb (>= 1.2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
aws-
|
11
|
-
aws-
|
10
|
+
aws-eventstream (1.0.0)
|
11
|
+
aws-partitions (1.91.0)
|
12
|
+
aws-sdk-core (3.21.2)
|
13
|
+
aws-eventstream (~> 1.0)
|
12
14
|
aws-partitions (~> 1.0)
|
13
15
|
aws-sigv4 (~> 1.0)
|
14
16
|
jmespath (~> 1.0)
|
15
|
-
aws-sdk-dynamodb (1.
|
17
|
+
aws-sdk-dynamodb (1.6.0)
|
16
18
|
aws-sdk-core (~> 3)
|
17
19
|
aws-sigv4 (~> 1.0)
|
18
20
|
aws-sigv4 (1.0.2)
|
19
21
|
diff-lcs (1.3)
|
20
|
-
jmespath (1.
|
22
|
+
jmespath (1.4.0)
|
21
23
|
rake (10.5.0)
|
22
24
|
rspec (3.7.0)
|
23
25
|
rspec-core (~> 3.7.0)
|
@@ -43,4 +45,4 @@ DEPENDENCIES
|
|
43
45
|
rspec (~> 3.0)
|
44
46
|
|
45
47
|
BUNDLED WITH
|
46
|
-
1.16.
|
48
|
+
1.16.1
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# DynamoDB helpers
|
2
2
|
|
3
3
|
Currently only the scan finder is implemented. It will issue multiple scans for each 1MB and combine them into a single result.
|
4
|
-
Dataset returned is a plain ruby hash which gives you significant speed-up if you are only interested in reading the data.
|
4
|
+
Dataset returned is a plain ruby hash which gives you significant speed-up over aws-record gem if you are only interested in reading the data.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -23,7 +23,10 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
#
|
26
|
+
# Instantiate the client which will require table_name option on each call
|
27
|
+
DynamoClient = Class.new.extend(DynamodbHelpers)
|
28
|
+
|
29
|
+
# or extend your class and provide table_name method
|
27
30
|
class User
|
28
31
|
extend DynamodbHelpers
|
29
32
|
|
@@ -34,7 +37,11 @@ end
|
|
34
37
|
|
35
38
|
# Find by multiple keys:
|
36
39
|
User.scan_and_find_by(name: 'Joe', email: 'joe@example.com')
|
37
|
-
# => {"name" => "Joe", "email" => "joe@example.com", ... other attributes}
|
40
|
+
# => [{"name" => "Joe", "email" => "joe@example.com", ... other attributes}, ...]
|
41
|
+
|
42
|
+
# Return specific fields:
|
43
|
+
User.scan_and_find_by({name: 'Joe', email: 'joe@example.com'}, select: [:email])
|
44
|
+
# => [{"email" => "joe@example.com"}, ...]
|
38
45
|
|
39
46
|
# Find by scanning in parallel with multiple threads:
|
40
47
|
User.scan_and_find_by({name: 'Joe'}, segments: 5)
|
data/dynamodb_helpers.gemspec
CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
27
|
|
28
|
-
|
28
|
+
spec.add_dependency "aws-sdk-dynamodb", ">= 1.2.0"
|
29
29
|
# spec.add_dependency "aws-sdk", "~> 2.0"
|
30
30
|
end
|
data/lib/dynamodb_helpers.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require "dynamodb_helpers/version"
|
2
2
|
|
3
3
|
module DynamodbHelpers
|
4
|
-
def scan_and_find_by(query_opts, opts = {segments: false})
|
5
|
-
|
4
|
+
def scan_and_find_by(query_opts, opts = {segments: false, select: false, table_name: false})
|
5
|
+
|
6
|
+
query = {table_name: opts[:table_name] ? opts[:table_name] : self.table_name, select: 'ALL_ATTRIBUTES', scan_filter: {}}
|
6
7
|
|
7
8
|
query_opts.each do | key, value |
|
8
|
-
if
|
9
|
+
if value.nil?
|
10
|
+
# raise "Detected nil value for #{key}"
|
11
|
+
return []
|
12
|
+
else
|
9
13
|
query[:scan_filter].merge!(key.to_s => {:comparison_operator => "EQ", :attribute_value_list => [value]})
|
10
14
|
end
|
11
15
|
end
|
@@ -14,6 +18,9 @@ module DynamodbHelpers
|
|
14
18
|
query.merge!(:conditional_operator => "AND")
|
15
19
|
end
|
16
20
|
|
21
|
+
# field selection
|
22
|
+
query.merge!(select: "SPECIFIC_ATTRIBUTES", attributes_to_get: opts[:select]) if opts[:select]
|
23
|
+
|
17
24
|
return scan_in_parallel(query, opts) if opts[:segments]
|
18
25
|
return scan_sequentialy(query)
|
19
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamodb_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damir Roso
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws-sdk-dynamodb
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.0
|
55
69
|
description: Lightweight wrapper for some aws-sdk-dynamodb features
|
56
70
|
email:
|
57
71
|
- damir.roso@nih.gov
|
@@ -93,9 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
107
|
version: '0'
|
94
108
|
requirements: []
|
95
109
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.6.
|
110
|
+
rubygems_version: 2.6.14.1
|
97
111
|
signing_key:
|
98
112
|
specification_version: 4
|
99
113
|
summary: Utility methods for dynamodb
|
100
114
|
test_files: []
|
101
|
-
has_rdoc:
|