set in Dynamo DB not properly incrementing nodejs lamnda function
var AWS = require('aws-sdk');
var documentClient = new AWS.DynamoDB.DocumentClient({'region': 'eu-central-1'});
exports.handler = function(item, context, callback) {
var params = {
TableName: "my-table",
Key:{
"id": item.id
},
UpdateExpression: "ADD iteration :iteration SET itemdata = :itemdata",
ExpressionAttributeValues:{
':iteration': 1,
':itemdata' : item.data
},
ReturnValues:"NONE"
};
documentClient.update(params, function(err, data) {
if (err) {
console.log("Error", err);
const errResponse = {
statusCode: 500,
headers: {
"Access-Control-Allow-Origin": "*"
},
body: JSON.stringify({ Error: 500, device : "DynamoDB", detail : err })
};
callback(null, errResponse);
} else {
console.log("Success", params.Items);
const response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin": "*"
},
body: JSON.stringify("upsert complete.")
};
callback(null, response);
}
});
};
Also in JavaScript:
- javascript count instances in string
- moment.js format
- image compression in nodejs
- es6 class example
- javascript promise
- javascript limit input to 2 decimal places
- update param in url jquery
- submit form automatically javascript
- javascript write to text file
- get all input values by class jquery
- olx clone react
- first child element javascript
- check if function javascript
- sql server for json path
- check if click is inside div javascript
- how the filter() function works javascript
- js check if is array
- discord.js embed
- how to run cypress
- how to post json to cloudwatch
- how to craete a shopping cart in node js
- sort array with negative numbers
- Javascript convert html entity to string
- bootstrap show modal jquery