- When adding a new row of data into DynamoDB, or updating an existing row in DynamoDB (when updating you have to resubmit the ENTIRE row since DynamoDB does not allow you to update a single column in an existing row) then you need to use put. The syntax below provides an example of putting a row of data:
var AWS = require("aws-sdk");
var docClient = new AWS.DynamoDB.DocumentClient();
var params = {};
params = {
TableName: "NameOfTable",
Item: {
ID: 123,
AddedBy: "pancakes",
Info: "Some sort of text to be added."
}
};
docClient.put(params, function(err, data) {
if (err) {
/* Generate Response */
context.done(
null,
{
"Error": JSON.stringify(err, null, 2)
}
);
}
else {
/* Generate Response */
context.done(
null,
{
"Success": "You have putted, but not a golf put."
}
);
}
});
|