Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
    }
  });
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: advanced data manipulation javascript 
Javascript :: if property is same group javscript 
Javascript :: get foco a div 
Javascript :: time second updating without rendering 
Javascript :: get item position in canvas 
Javascript :: disable save image option 
Javascript :: choropleth map of india which shows current date confirmed cases in every state json api python. 
Javascript :: promises and not callbacks 
Javascript :: new activexobject( adodb.connection ) javascript 
Javascript :: simple javascript router 
Javascript :: leaflet draw save event 
Javascript :: 5.625/2 
Javascript :: youtube movie trailer angular 
Javascript :: Updating Object Properties 
Javascript :: send props from one component to another on button click 
Javascript :: how to display data from json api using flutter expansiontile 
Javascript :: heroku node js h21 backend connection refused 
Javascript :: using slice and reduce together in javascript 
Javascript :: decrease touchableopacity in react native 
Javascript :: how to add a object in world in matter.js 
Javascript :: message.author 
Javascript :: get image center pixels nodejs 
Javascript :: removeeventlistener not working in class javascript 
Javascript :: react native multiline cursor on first line 
Javascript :: on first time this.file.readAsDataURL not working ios 
Javascript :: Nodejs - non-flowing data stream 
Javascript :: add backgorund image in react native app 
Javascript :: selectize get instance id from onchange 
Javascript :: different db connectons depending on env in typeorm 
Javascript :: 4.6.3. Order of Operations¶ 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =