Created
October 23, 2017 03:25
-
-
Save kinlane/d00a6698b637708d215a96d74b4ea070 to your computer and use it in GitHub Desktop.
updateAccount
This file contains 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 characters
console.log('Loading event'); | |
var AWS = require('aws-sdk'); | |
var dynamodb = new AWS.DynamoDB(); | |
exports.handler = function(event, context) { | |
var tableName = "accounts"; | |
var datetime = new Date().getTime().toString(); | |
dynamodb.updateItem({ | |
"TableName": tableName, | |
"Key": { | |
"account_id": { | |
"S": event.account_id | |
} | |
}, | |
"UpdateExpression": "set first_name = :val1, last_name = :val2", | |
"ExpressionAttributeValues": { | |
":val1": {"S": event.first_name}, | |
":val2": {"S": event.last_name} | |
}, | |
"ReturnValues": "ALL_NEW", | |
}, function(err, data) { | |
if (err) { | |
context.fail('ERROR: Dynamo failed: ' + err); | |
} else { | |
console.log('Dynamo Success: ' + JSON.stringify(data, null, ' ')); | |
context.succeed('SUCCESS'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment