dynamodb_framework 1.3.0 → 1.4.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dynamodb_framework/dynamodb_index.rb +119 -0
  3. data/lib/dynamodb_framework/dynamodb_query.rb +111 -0
  4. data/lib/dynamodb_framework/dynamodb_repository.rb +37 -7
  5. data/lib/dynamodb_framework/dynamodb_table.rb +114 -0
  6. data/lib/dynamodb_framework/version.rb +1 -1
  7. data/lib/dynamodb_framework.rb +20 -0
  8. data/spec/dynamodb_index_spec.rb +212 -0
  9. data/spec/dynamodb_migration_manager_spec.rb +134 -0
  10. data/spec/dynamodb_namespace_migration_manager_spec.rb +134 -0
  11. data/spec/dynamodb_query_spec.rb +87 -0
  12. data/spec/dynamodb_repository_spec.rb +306 -0
  13. data/spec/dynamodb_table_manager_spec.rb +156 -0
  14. data/spec/dynamodb_table_spec.rb +245 -0
  15. data/spec/example_index.rb +45 -0
  16. data/spec/example_table.rb +41 -0
  17. data/spec/hash_helper_spec.rb +129 -0
  18. data/spec/spec_helper.rb +34 -0
  19. data/spec/test_item.rb +6 -0
  20. data/spec/test_migration_script1.rb +24 -0
  21. data/spec/test_migration_script2.rb +24 -0
  22. metadata +35 -25
  23. data/.gitignore +0 -14
  24. data/.idea/.name +0 -1
  25. data/.idea/.rakeTasks +0 -7
  26. data/.idea/encodings.xml +0 -6
  27. data/.idea/misc.xml +0 -33
  28. data/.idea/modules.xml +0 -8
  29. data/.idea/vcs.xml +0 -6
  30. data/.rspec +0 -3
  31. data/CODE_OF_CONDUCT.md +0 -49
  32. data/Gemfile +0 -12
  33. data/LICENSE.txt +0 -21
  34. data/README.md +0 -394
  35. data/Rakefile +0 -2
  36. data/dynamodb_framework.gemspec +0 -29
  37. data/script/cleanup.sh +0 -6
  38. data/script/container_loop.sh +0 -6
  39. data/script/docker-compose.yml +0 -5
  40. data/script/restart.sh +0 -3
  41. data/script/start.sh +0 -4
  42. data/script/stop.sh +0 -2
  43. data/yard.sh +0 -3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamodb_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-09 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,7 +73,21 @@ dependencies:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
- type: :development
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
@@ -102,41 +116,37 @@ executables: []
102
116
  extensions: []
103
117
  extra_rdoc_files: []
104
118
  files:
105
- - ".gitignore"
106
- - ".idea/.name"
107
- - ".idea/.rakeTasks"
108
- - ".idea/encodings.xml"
109
- - ".idea/misc.xml"
110
- - ".idea/modules.xml"
111
- - ".idea/vcs.xml"
112
- - ".rspec"
113
- - CODE_OF_CONDUCT.md
114
- - Gemfile
115
- - LICENSE.txt
116
- - README.md
117
- - Rakefile
118
119
  - bin/console
119
120
  - bin/setup
120
- - dynamodb_framework.gemspec
121
121
  - lib/dynamodb_framework.rb
122
122
  - lib/dynamodb_framework/dynamodb_attributes_builder.rb
123
+ - lib/dynamodb_framework/dynamodb_index.rb
123
124
  - lib/dynamodb_framework/dynamodb_logger.rb
124
125
  - lib/dynamodb_framework/dynamodb_migration_manager.rb
125
126
  - lib/dynamodb_framework/dynamodb_migration_script.rb
126
127
  - lib/dynamodb_framework/dynamodb_namespace_migration_manager.rb
128
+ - lib/dynamodb_framework/dynamodb_query.rb
127
129
  - lib/dynamodb_framework/dynamodb_repository.rb
128
130
  - lib/dynamodb_framework/dynamodb_store.rb
131
+ - lib/dynamodb_framework/dynamodb_table.rb
129
132
  - lib/dynamodb_framework/dynamodb_table_manager.rb
130
133
  - lib/dynamodb_framework/hash_helper.rb
131
134
  - lib/dynamodb_framework/version.rb
132
- - script/cleanup.sh
133
- - script/container_loop.sh
134
- - script/docker-compose.yml
135
- - script/restart.sh
136
- - script/start.sh
137
- - script/stop.sh
138
- - yard.sh
139
- homepage: https://github.com/vaughanbrittonsage/dynamodb_framework
135
+ - spec/dynamodb_index_spec.rb
136
+ - spec/dynamodb_migration_manager_spec.rb
137
+ - spec/dynamodb_namespace_migration_manager_spec.rb
138
+ - spec/dynamodb_query_spec.rb
139
+ - spec/dynamodb_repository_spec.rb
140
+ - spec/dynamodb_table_manager_spec.rb
141
+ - spec/dynamodb_table_spec.rb
142
+ - spec/example_index.rb
143
+ - spec/example_table.rb
144
+ - spec/hash_helper_spec.rb
145
+ - spec/spec_helper.rb
146
+ - spec/test_item.rb
147
+ - spec/test_migration_script1.rb
148
+ - spec/test_migration_script2.rb
149
+ homepage: https://github.com/sage/dynamodb_framework
140
150
  licenses:
141
151
  - MIT
142
152
  metadata: {}
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- .DS_Store*
11
- .idea/*
12
- .idea
13
- pkg
14
-
data/.idea/.name DELETED
@@ -1 +0,0 @@
1
- dynamodb_framework
data/.idea/.rakeTasks DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Settings><!--This file was automatically generated by Ruby plugin.
3
- You are allowed to:
4
- 1. Remove rake task
5
- 2. Add existing rake tasks
6
- To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build dynamodb_framework-1.2.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install dynamodb_framework-1.2.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install dynamodb_framework-1.2.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v1.2.0 and build and push dynamodb_framework-1.2.0.gem to Rubygems" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
data/.idea/encodings.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="Encoding">
4
- <file url="PROJECT" charset="UTF-8" />
5
- </component>
6
- </project>
data/.idea/misc.xml DELETED
@@ -1,33 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectInspectionProfilesVisibleTreeState">
4
- <entry key="Project Default">
5
- <profile-state>
6
- <expanded-state>
7
- <State>
8
- <id />
9
- </State>
10
- <State>
11
- <id>Ruby</id>
12
- </State>
13
- </expanded-state>
14
- <selected-state>
15
- <State>
16
- <id>RubyConvertAllHashesInFileInspections</id>
17
- </State>
18
- </selected-state>
19
- </profile-state>
20
- </entry>
21
- </component>
22
- <component name="ProjectLevelVcsManager" settingsEditedManually="false">
23
- <OptionsSetting value="true" id="Add" />
24
- <OptionsSetting value="true" id="Remove" />
25
- <OptionsSetting value="true" id="Checkout" />
26
- <OptionsSetting value="true" id="Update" />
27
- <OptionsSetting value="true" id="Status" />
28
- <OptionsSetting value="true" id="Edit" />
29
- <ConfirmationsSetting value="0" id="Add" />
30
- <ConfirmationsSetting value="0" id="Remove" />
31
- </component>
32
- <component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 2.1.5" project-jdk-type="RUBY_SDK" />
33
- </project>
data/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/dynamodb_framework.iml" filepath="$PROJECT_DIR$/.idea/dynamodb_framework.iml" />
6
- </modules>
7
- </component>
8
- </project>
data/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --require spec_helper
3
- --format doc
data/CODE_OF_CONDUCT.md DELETED
@@ -1,49 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at vaughan.britton@sage.com. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in dynamodb_framework.gemspec
4
- gemspec
5
-
6
- group :test, :development do
7
- gem 'yard'
8
- end
9
-
10
- group :test do
11
- gem 'simplecov', :require => false
12
- end
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 vaughanbrittonsage
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,394 +0,0 @@
1
- # DynamoDb_Framework
2
-
3
- Welcome to DynamoDb_Framework, this is a light weight framework that provides managers to help with interacting with aws dynamodb.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'dynamodb_framework'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install dynamodb_framework
20
-
21
- ## Usage
22
-
23
- # MigrationScripts
24
- To create or modify a DynamoDb instance you first need to create a migration script:
25
-
26
- **Example**
27
-
28
- class CreateEventTrackingTableScript < DynamoDbFramework::MigrationScript
29
-
30
- def initialize
31
- #set the timestamp for when this script was created
32
- @timestamp = '20160318110710'
33
- end
34
-
35
- def apply
36
- #create an instance of the table manager
37
- manager = DynamoDbFramework::TableManager.new
38
- #create an attribute builder
39
- builder = DynamoDbFramework::AttributesBuilder.new
40
-
41
- #set the hash key attribute
42
- builder.add(:type, :S)
43
-
44
- #create the table
45
- manager.create('event_tracking', builder.attributes, :type)
46
- end
47
- def undo
48
-
49
- #create an instance of the table manager
50
- manager = DynamoDbFramework::TableManager.new
51
-
52
- #drop the table
53
- manager.drop('event_tracking')
54
-
55
- end
56
- end
57
-
58
- Each migration script should have a unique fixed timestamp value of the following format:
59
-
60
- yyyymmddhhMMss
61
-
62
- **Example**
63
-
64
- 11:07:10 18-03-2016 would be:
65
-
66
- 20160318110710
67
-
68
- This timestamp is used to track installation of each migration script and insure correct apply/undo ordering.
69
-
70
- # DynamoDbMigrationManager
71
- This manager is called to apply/rollback migration script changes against a DynamoDb instance.
72
-
73
- ### #connect
74
- This method is called to connect the manager to the DynamoDb instance. If the migration manager has never been connected to the instance then the 'dynamodb_migrations' table will be created to record migration script executions.
75
-
76
- **Example**
77
-
78
- manager = DynamoDbFramework::MigrationManager.new
79
- manager.connect
80
-
81
- ### #apply
82
- This method is called to execute any migration scripts (in chronological order) that have not been executed against the current DynamoDb instance.
83
-
84
- **Example**
85
-
86
- #apply any outstanding migration scripts
87
- manager.apply
88
-
89
- ### #rollback
90
- This method is called to rollback the last migration script that was executed against the current DynamoDb instance.
91
-
92
- #rollback the last migration script
93
- manager.rollback
94
-
95
- # DynamoDbFramework::TableManager
96
-
97
- This manager object provides the following methods for managing tables within a DynamoDb instance.
98
-
99
- ### #create
100
-
101
- This method is called to create a table within DynamoDb.
102
-
103
- **Params**
104
-
105
- - **table_name** [String] [Required] This is used to specify the name of the table to create. (Must be unique within the DynamoDb instance).
106
- - **attributes** [Hash] [Required] This is used to specify the attributes used by the keys and indexes. (Use the DynamoDbFramework::AttributesBuilder to create attributes)
107
- - **partition_key** [Symbol] [Required] This is the document attribute that will be used as the partition key of this table.
108
- - **range_key** [Symbol / nil] [Optional] This is the document attribute that will be used as the range key for this table.
109
- - **read_capacity** [Number] [Default=20] This is the read throughput required for this table.
110
- - **write_capacity** [Number] [Default=10] This is the write throughput required for this table.
111
- - **global_indexes** [Array / nil] [Optional] This is an array of the global indexes to create for this table. (Use the ***#create_global_index*** method to create each global index required and populate an array for this parameter).
112
-
113
- **Examples**
114
-
115
- Table with partition key, no range key and no indexes:
116
-
117
- #create an attribute builder
118
- builder = DynamoDbFramework::AttributesBuilder.new
119
-
120
- #set the partition key attribute
121
- builder.add(:type, :S)
122
-
123
- #create the table
124
- manager.create('event_tracking', builder.attributes, :type)
125
-
126
- Table with partition key, range key and no indexes:
127
-
128
- #create an attribute builder
129
- builder = DynamoDbFramework::AttributesBuilder.new
130
-
131
- #set the partition key attribute
132
- builder.add(:type, :S)
133
- #set the range key attribute
134
- builder.add(:timestamp, :S)
135
-
136
- #create the table
137
- manager.create('event_tracking', builder.attributes, :type, :timestamp)
138
-
139
- Table with a global index:
140
-
141
- #create an attribute builder
142
- builder = DynamoDbFramework::AttributesBuilder.new
143
-
144
- #set the partition key attribute
145
- builder.add(:id, :S)
146
-
147
- global_indexes = []
148
- #create the global index
149
- index = manager.create_global_index('type_index', :type)
150
- #add the index to the global_indexes array
151
- global_indexes.push(index)
152
-
153
- #create the table and the index
154
- manager.create('event_tracking', builder.attributes, :id, :nil, 20, 10, global_indexes)
155
-
156
- ### #drop
157
- This method is called to drop a table.
158
-
159
- > **WARNING**: *This will drop all data stored within the table*
160
-
161
- **Params**
162
-
163
- - **table_name** [String] [Required] This is the name of the table to drop.
164
-
165
- **Example**
166
-
167
- #drop the table
168
- manager.drop('event_tracking')
169
-
170
- ### #exists?(table_name)
171
-
172
- This method is called to check if a table exists within the database.
173
-
174
- manager.exists?('event_tracking')
175
- => true
176
-
177
-
178
- ### #add_index
179
- This method is called to add an index to an existing table.
180
-
181
- **Params**
182
-
183
- - **table_name** [String] [Required] This is the name of the index. (Must be unique within the scope of the table)
184
- - **attributes** [Hash] [Required] This is the document attributes used by the table keys and index keys. (Use the DynamoDbFramework::AttributesBuilder to create the attributes hash.)
185
- - **global_index** [Hash] [Required] This is the global index to add to the table. (Use the ***#create_global_index*** method to create the global index hash.)
186
-
187
- **Example**
188
-
189
- #build the attributes hash
190
- builder = DynamoDbFramework::AttributesBuilder.new
191
- #add the attribute for the tables partition key & range key (if range key required)
192
- builder.add(:id, :S)
193
- #add the attributes for the index partition key and range key (if required)
194
- builder.add(:type, :S)
195
-
196
- #create the index hash
197
- index = manager.create_global_index('type_index', :type)
198
-
199
- #add the index to the table
200
- manager.add_index('event_tracking', builder.attributes, index)
201
-
202
-
203
- ### #drop_index
204
- This method is called to drop an existing index from a table.
205
-
206
- **Params**
207
-
208
- - **table_name** [String] [Required] This is the name of the table you want to remove the index from.
209
- - **index_name** [String] [Required] This is the name of the index you want to remove.
210
-
211
- **Example**
212
-
213
- #drop the index
214
- manager.drop_index('event_tracking', 'type_index')
215
-
216
- ### #update_index_throughput
217
-
218
- This method is called to update the throughput required by an index.
219
-
220
- **Params**
221
-
222
- - **table_name** [String] [Required] This is the name of the table the index belongs to.
223
- - **index_name** [String] [Required] This is the name of the index to update.
224
- - **read_capacity** [Number] [Required] This is the read throughput required per second.
225
- - **write_capacity** [Number] [Required] This is the write throughput required per second.
226
-
227
- **Example**
228
-
229
- #update the index
230
- manager.update_index_throughput('event_tracking', 'type_index', 50, 20)
231
-
232
- ### #has_index?(table_name, index_name)
233
-
234
- This method is called to check if an index exists on a table within the database.
235
-
236
- manager.has_index?('event_tracking', 'event_type')
237
- => true
238
-
239
-
240
- # DynamoDbFramework::Repository
241
-
242
- This is a base repository that exposes core functionality for interacting with a DynamoDb table. It is intended to be wrapped inside of a table specific repository, and is only provided to give a common way of interacting with a DynamoDb table.
243
-
244
- Before calling any methods from the repository the **.table_name** attribute must be set so that the repository knows which table to run the operations against.
245
-
246
- **Example**
247
-
248
- repository.table_name = 'event_tracking'
249
-
250
- ### #put
251
- This method is called to insert an item into a DynamoDb table.
252
-
253
- *Note*:
254
-
255
- [DateTime] attributes will be stored as an ISO8601 string
256
-
257
- [Time] attributes will be stored as an Epoch Int
258
-
259
- The intent is that if you need to sort in dynamo by dates, then make sure you use a [Time] type. The Epoch int allows
260
- you to compare properly as comparing date strings are not reliable.
261
-
262
- **Params**
263
-
264
- - **item** [Object] [Required] The document to store within the table.
265
-
266
- **Example**
267
-
268
- #add the document object to the table
269
- repository.put(item)
270
-
271
- ### #delete
272
-
273
- This method is called to delete a document from a DynamoDb table.
274
-
275
- **Params**
276
-
277
- - **keys** [Hash] [Required] This is a hash of the primary key of the document you want to delete. (The keys hash should contain the partition_key and if the table requires it the range_key.)
278
-
279
- **Example**
280
-
281
- #delete an item where the partition key (:id) is the primary key
282
- repository.delete({ :id => '012' })
283
-
284
- #delete an item where the partition key (:type) and the range key (:index) is the primary key
285
- repository.delete({ :type => 'list', :index => 2 })
286
-
287
- ### #get_by_key
288
- This method is called to get a single item from a table by its key.
289
-
290
- **Params**
291
-
292
- - **partition_key** [Symbol] [Required] This is the document attribute that is the partition key for the table.
293
- - **partition_key_value** [String / Number] [Required] This is the value of the documents partition key.
294
- - **range_key** [Symbol] [Optional] This is the document attribute that is the range key for the table.
295
- - **range_key_value** [String / Number] [Optional] This is the value of the documents range key.
296
-
297
- **Example**
298
-
299
- #get an item where the partition key is the primary key
300
- item = repository.get(:id, '12345')
301
-
302
- #get an item where the partition key and the range key is the primary key
303
- item = repository.get(:type, 'list', :index, 2)
304
-
305
-
306
- ### #all
307
- This method is called to get all items from a table.
308
-
309
- **Example**
310
-
311
-
312
- #get all items from table
313
- all_items_array = repository.all
314
-
315
- ### #scan
316
- This method is called to execute a query against an entire table bypassing any indexes.
317
-
318
- > **WARNING:** *Full table scans are slower than queries ran against a global index.*
319
-
320
- **Params**
321
-
322
- - **expression** [String] [Required] This is an expression string for that contains the filter expression to run against the full table scan.
323
- - **expression_params** [Hash] [Required] This is a hash that contains the parameter names & values used by parameters within the scan expression.
324
- - **limit** [Number] [Optional] This is used to specify a limit to the number of records returned by the scan query.
325
- - **count** [Bool] [Optional] This is used to specify that the scan query should only return a count of the items that match the scan query.
326
-
327
- **Example**
328
-
329
- #scan the table and return matching items
330
- results = repository.scan('#type = :type and #index > :index', { '#type' => :type, ':type' => 'list', '#index' => :index, ':index' => 2 })
331
-
332
- #scan the table and return matching items limited to 5 results
333
- results = repository.scan('#type = :type and #index > :index', { '#type' => :type, ':type' => 'list', '#index' => :index, ':index' => 2 }, 5)
334
-
335
- #scan the table and return a count of matching items
336
- count = repository.scan('#type = :type and #index > :index', { '#type' => :type, ':type' => 'list', '#index' => :index, ':index' => 2 }, nil, true)
337
-
338
- > **Notes:**
339
- >
340
- > Attribute names should be specified using Expression parameter names which should start with a #
341
- >
342
- > Attribute values should be specified using Expression parameter values which should start with a :
343
-
344
-
345
- ### #query
346
- This method is called to execute a query against either a table partition or an index.
347
-
348
- **Params**
349
-
350
- - **partition_key_name** [Symbol] [Required] This is used to specify the attribute that is used as the partition key for this table.
351
- - **partition_key_value** [String / Number] [Required] This is used to specify the value of the partition to run this query against.
352
- - **range_key_name** [Symbol] [Optional] This is used to specify the range key to run this query against if needed.
353
- - **range_key_value** [String / Number] [Optional] This is used to specify the value of the range key to run this query against if needed.
354
- - **expression** [String] [Required] This is an expression string used to specify the filter to run against the records found within the partition/range.
355
- - **expression_params** [Hash] [Required] This is a hash that contains the parameter names & values used by parameters within the query expression.
356
- - **index_name** [String] [Optional] This is the name of the index to run this query against.
357
- - **limit** [Number] [Optional] This is used to specify a limit to the number of records returned by the query.
358
- - **count** [Bool] [Optional] This is used to specify that the scan query should only return a count of the items that match the query.
359
-
360
- **Examples**
361
-
362
- Query from a table partition without an index:
363
-
364
- results = repository.query(:name, 'name 1', nil, nil, '#number > :number', { '#number' => 'number', ':number' => 2})
365
-
366
- Query and Count from a table partition without an index:
367
-
368
- count = repository.query(:name, 'name 1', nil, nil, '#number > :number', { '#number' => 'number', ':number' => 2}, nil, nil, true)
369
-
370
- Query from an index partition:
371
-
372
- results = repository.query(:name, 'name 1', nil, nil, '#number > :number', { '#number' => 'number', ':number' => 2}, 'name_index')
373
-
374
- > **Notes:**
375
- >
376
- > Attribute names should be specified using Expression parameter names which should start with a #
377
- >
378
- > Attribute values should be specified using Expression parameter values which should start with a :
379
-
380
-
381
- ## Development
382
-
383
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
384
-
385
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
386
-
387
- ## Contributing
388
-
389
- Bug reports and pull requests are welcome on GitHub at https://github.com/vaughanbrittonsage/dynamodb_framework. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
390
-
391
-
392
- ## License
393
-
394
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec