-
-
Save carlows/08211ce2ec0c68bb24b07265c45d02ca to your computer and use it in GitHub Desktop.
Revisions
-
kenoir revised this gist
Feb 14, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,6 +49,7 @@ dynamo_db.tables.each {|x| if x.name == foobar then x.delete end } client = AWS::DynamoDB::Client::V20120810.new client.query({ :table_name => 'foobar', :consistent_read => true, :select => 'SPECIFIC_ATTRIBUTES', :attributes_to_get => ['s3_location'], :key_conditions => { -
kenoir revised this gist
Feb 14, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,5 +67,5 @@ client.query({ } }) # => {:member=>[{"s3_location"=>{:s=>"foo/bar/baz"}}], :count=>1} ``` -
kenoir revised this gist
Feb 14, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,4 +67,5 @@ client.query({ } }) # => => {:member=>[{"s3_location"=>{:s=>"foo/bar/baz"}}], :count=>1} ``` -
kenoir revised this gist
Feb 14, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,7 +49,8 @@ dynamo_db.tables.each {|x| if x.name == foobar then x.delete end } client = AWS::DynamoDB::Client::V20120810.new client.query({ :table_name => 'foobar', :select => 'SPECIFIC_ATTRIBUTES', :attributes_to_get => ['s3_location'], :key_conditions => { 'component_id' => { :comparison_operator => 'EQ', -
kenoir revised this gist
Feb 14, 2014 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,6 +55,12 @@ client.query({ :comparison_operator => 'EQ', :attribute_value_list => [ { 's' => '1' } ], }, 'opts_hash' => { :comparison_operator => 'EQ', :attribute_value_list => [ { 's' => 'def' } ] } } -
kenoir revised this gist
Feb 14, 2014 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,6 +27,9 @@ foobar.status # => :active (takes ~15 seconds) foobar.hash_key # => <AWS::DynamoDB::PrimaryKeyElement:0x60cd375d @name="component_id", @type=:string> foobar.range_key # => <AWS::DynamoDB::PrimaryKeyElement:0x48774b2c @name="opts_hash", @type=:string> # Get table dynamo_db.tables['foobar'] # Create Item item1 = foobar.items.create( :component_id => '1', @@ -46,8 +49,9 @@ dynamo_db.tables.each {|x| if x.name == foobar then x.delete end } client = AWS::DynamoDB::Client::V20120810.new client.query({ :table_name => 'foobar', :select => 'ALL_ATTRIBUTES', :key_conditions => { 'component_id' => { :comparison_operator => 'EQ', :attribute_value_list => [ { 's' => '1' } -
kenoir revised this gist
Feb 14, 2014 . 1 changed file with 4 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,18 +30,14 @@ foobar.range_key # => <AWS::DynamoDB::PrimaryKeyElement:0x48774b2c @name="opts_h # Create Item item1 = foobar.items.create( :component_id => '1', :opts_hash => 'abc', :s3_location => 'foo/bar/baz' ) # => <AWS::DynamoDB::Item table_name:foobar hash_value:1 range_value:abc> # Retrieve Items foobar.items.each { |item| puts item.attributes.to_h } # => {"s3_location"=>"foo/bar/baz", "component_id"=>"1", "opts_hash"=>"def"} # Delete Tables dynamo_db.tables.each {|x| if x.name == foobar then x.delete end } -
kenoir revised this gist
Feb 14, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ [AWS query-instance_method docs](http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/DynamoDB/Client/V20120810.html#query-instance_method) ```sh export AWS_ACCESS_KEY_ID=‘XXXX’ export AWS_SECRET_ACCESS_KEY=‘XXXX’ -
kenoir revised this gist
Feb 14, 2014 . No changes.There are no files selected for viewing
-
kenoir created this gist
Feb 14, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ ```sh export AWS_ACCESS_KEY_ID=‘XXXX’ export AWS_SECRET_ACCESS_KEY=‘XXXX’ ``` ```rb # ENV['AWS_ACCESS_KEY_ID'] # ENV['AWS_SECRET_ACCESS_KEY'] require 'aws-sdk' dynamo_db = AWS::DynamoDB.new # Create table foobar = dynamo_db.tables.create( 'foobar', 10, 5, :hash_key => { :component_id => :string }, :range_key => { :opts_hash => :string } ) foobar.status # => :creating foobar.status # => :active (takes ~15 seconds) foobar.hash_key # => <AWS::DynamoDB::PrimaryKeyElement:0x60cd375d @name="component_id", @type=:string> foobar.range_key # => <AWS::DynamoDB::PrimaryKeyElement:0x48774b2c @name="opts_hash", @type=:string> # Create Item item1 = foobar.items.create( :component_id => '1', :opts_hash => 'abc' ) # => <AWS::DynamoDB::Item table_name:foobar hash_value:1 range_value:abc> # Retrieve Items foobar.items # => <AWS::DynamoDB::ItemCollection> foobar.items.each { |item| puts item.range_value } # => abc, def item2 = foobar.items.create(:component_id => '1', :opts_hash => 'def') foobar.items.each { |item| puts item.hash_value } # => 1, 1 # Delete Tables dynamo_db.tables.each {|x| if x.name == foobar then x.delete end } # Query Tables client = AWS::DynamoDB::Client::V20120810.new client.query({ :table_name => 'foobar', :key_conditions => { :component_id => { :comparison_operator => 'EQ', :attribute_value_list => [ { 's' => '1' } ] } } }) ```