1

I have a lambda function which is updating data in DynamoDB table(Based on specific user properties I want to change some values for that user.). When It gets executed first time then it doesn't work, but on second execution it updates the data. It works alternatively. one time it updates and one time it doesn't. What could be the reason for this.

Based on specific user properties I want to change some values for that user.

2
  • 2
    Could it be a read consistency issue (docs.aws.amazon.com/amazondynamodb/latest/developerguide/…)? More details on how you've set up the table and some code are needed. Commented Oct 19, 2021 at 12:04
  • 1
    Indeed we need to see some code and some concrete examples of what you have tried to do in order to help diagnose the problem Commented Oct 19, 2021 at 12:26

1 Answer 1

1

This sounds like a syntax error while using or not using await and .promise()

Also out of experience there occur problems like you described it when you call it like this:

await nameOfDb.update(params, function (err, data) {   
      if (err) console.log(err, err.stack);   
      else     console.log(data); 
}).promise();

which is the recommended way to call .update() in the doc

so I prefer using

Try {
    await nameOfDb.update(params).promise();
} 
catch (e) {
    console.log(e);
}

which always works as I want it to work when using .update()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.