Skip to content

Instantly share code, notes, and snippets.

@tomnagengast
Last active August 21, 2017 19:06
Show Gist options
  • Save tomnagengast/3263d2b19768395db790d6aad4103837 to your computer and use it in GitHub Desktop.
Save tomnagengast/3263d2b19768395db790d6aad4103837 to your computer and use it in GitHub Desktop.
DynamoDB Examples
dynamodb.updatedItem({
TableName: 'Url',
Key: {
'ShortUrl': 'short.url.example/4ua93',
},
UpdateExpression: `SET
Usage.Views = Usage.Views + :increment_by,
Usage.LastVisited = :now
`,
ExpressionAttributeValues: {
':increment_by': 1,
':now': new Date().toISOString(),
},
ReturnValues: 'ALL_NEW',
ConditionExpression:: 'attribute_exists(ShortUrl)',
}, (error, data) {
if (error) return console.log(error);
console.log(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment