dynamini 2.1.1 → 2.1.2
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/Gemfile.lock +1 -1
- data/README.md +14 -1
- data/dynamini.gemspec +1 -1
- data/lib/dynamini/test_client.rb +1 -1
- data/spec/dynamini/test_client_spec.rb +17 -0
- 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: f7b0c9b660d05e9791a38a79ee09b2847d9dff48
|
4
|
+
data.tar.gz: 5262cf9c63c4a2152a1182c2037712855e35ffda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad4de22dd7dce271017ee4badda3ce8babc3bb3b97592f88bb03c2485af77fc74a621e0bea47c7f9c610d7e39c2b7ac939fdbdf4b67672bccc5cabe20a769952
|
7
|
+
data.tar.gz: 06646d44a9ae44ae92560f4800ce3a5c6421405b915ab3dbcce0e721d246f3b1eaab59ac7122307025ee2b09246ee27050dea5ea9f2961eb09645f9daaf54e88
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -105,7 +105,14 @@ The magic fields updated_at and created_at are handled as :time by default.
|
|
105
105
|
|
106
106
|
Dynamini includes a query function that's much more narrow than ActiveRecord's where function. It's designed to retrieve a selection of records that belong to a given hash key but have various range key values. To use .query, your table needs to be configured with a range key, and you need to :handle that range field as a fundamentally numeric type - integer, float, date, or time. If your range key field isn't numeric, you won't be able to .query, but you'll still be able to .find your records normally.
|
107
107
|
|
108
|
-
Query takes
|
108
|
+
Query takes the following arguments:
|
109
|
+
* :hash_key (required)
|
110
|
+
* :start (optional)
|
111
|
+
* :end (optional)
|
112
|
+
* :limit (optional)
|
113
|
+
* :scan_index_forward (optional - set to false to sort by range key in desc order)
|
114
|
+
|
115
|
+
Here's how you'd use it to find daily temperature data for a given city, selecting for specific date ranges:
|
109
116
|
|
110
117
|
```ruby
|
111
118
|
class DailyWeather < Dynamini::Base
|
@@ -138,6 +145,12 @@ DailyWeather.query(hash_key: "Toronto", end: Date.new(2015,10,08))
|
|
138
145
|
|
139
146
|
DailyWeather.query(hash_key: "Toronto", start: Date.new(2015,10,08), end: Date.new(2015,10,09))
|
140
147
|
> [A, B]
|
148
|
+
|
149
|
+
DailyWeather.query(hash_key: "Toronto", limit: 2)
|
150
|
+
> [A, B]
|
151
|
+
|
152
|
+
DailyWeather.query(hash_key: "Toronto", scan_index_forward: false)
|
153
|
+
> [C, B, A]
|
141
154
|
```
|
142
155
|
|
143
156
|
## Array Support
|
data/dynamini.gemspec
CHANGED
data/lib/dynamini/test_client.rb
CHANGED
@@ -103,7 +103,7 @@ module Dynamini
|
|
103
103
|
end
|
104
104
|
|
105
105
|
tokens = args[:key_condition_expression].split(/\s+/)
|
106
|
-
hash_key = tokens[2]
|
106
|
+
hash_key = args[:expression_attribute_values][":h"].is_a?(Integer) ? tokens[2].to_i : tokens[2]
|
107
107
|
case tokens[5]
|
108
108
|
when ">="
|
109
109
|
start_val = tokens[6]
|
@@ -106,6 +106,23 @@ describe Dynamini::TestClient do
|
|
106
106
|
test_client.update_item(table_name: table_name, key: {hash_key_field: 'foo', range_key_field: i + 1}, attribute_updates: {abc: {value: 'abc', action: 'PUT'}})
|
107
107
|
end
|
108
108
|
end
|
109
|
+
|
110
|
+
context 'on table with integer hash_key' do
|
111
|
+
it 'should return items correctly' do
|
112
|
+
test_client.update_item(table_name: 'integer_table', key: {hash_key_field: 1, range_key_field: 1}, attribute_updates: {abc: {value: 'abc', action: 'PUT'}})
|
113
|
+
response = test_client.query(
|
114
|
+
table_name: 'integer_table',
|
115
|
+
key_condition_expression: "hash_key_field = :h",
|
116
|
+
expression_attribute_values: {
|
117
|
+
":h" => 1
|
118
|
+
}
|
119
|
+
)
|
120
|
+
expect(response.items.length).to eq(1)
|
121
|
+
expect(response.items.first[:range_key_field]).to eq(1)
|
122
|
+
expect(response.items.first[:hash_key_field]).to eq(1)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
109
126
|
context 'with LE operator' do
|
110
127
|
it 'should return all items with range key less than or equal to the provided value' do
|
111
128
|
response = test_client.query(
|
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.1.
|
4
|
+
version: 2.1.2
|
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: 2016-
|
18
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activemodel
|