Skip to content

Instantly share code, notes, and snippets.

@onedal
Created February 16, 2017 01:10
Show Gist options
  • Save onedal/d1e7241fce91f50b1ca21339bc5c17f7 to your computer and use it in GitHub Desktop.
Save onedal/d1e7241fce91f50b1ca21339bc5c17f7 to your computer and use it in GitHub Desktop.
Dynamo increment for ruby
client = Aws::DynamoDB::Client.new(
region: Rails.application.secrets.dynamo_region,
credentials: Aws::Credentials.new(key,secret)
)
params = {
table_name: 'table_name',
key:{
'id': self.object_id
},
update_expression: 'set comments = comments + :val',
expression_attribute_values:{
':val': 1
},
return_values: 'UPDATED_NEW'
}
client.update_item(params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment