Created
November 18, 2018 13:04
-
-
Save vishwasnavadak/40077dd29c9c4ccd50f2fd1a1300070c to your computer and use it in GitHub Desktop.
Lambda Functions to add data to DynamoDB
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
var uid = require('uuid'); | |
var AWS = require('aws-sdk'), | |
myDocumentClient = new AWS.DynamoDB.DocumentClient(); | |
exports.todoGetItem = function(event, context, callback) { | |
var params ={ | |
TableName: 'TABLE_NAME', | |
Item: { | |
'id' : uid.v1(), | |
'desc' : event.desc, | |
'isCompleted' : false, | |
'timestamp' : new Date(Date.now()).toString() | |
} | |
}; | |
myDocumentClient.put(params, function(err, data) { | |
if (err) { | |
console.log("Error", err); | |
} else { | |
console.log("Success", data); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment