Skip to content

Instantly share code, notes, and snippets.

@vishwasnavadak
Created November 18, 2018 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vishwasnavadak/40077dd29c9c4ccd50f2fd1a1300070c to your computer and use it in GitHub Desktop.
Save vishwasnavadak/40077dd29c9c4ccd50f2fd1a1300070c to your computer and use it in GitHub Desktop.
Lambda Functions to add data to DynamoDB
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