Reputation: 167
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.
Upvotes: 1
Views: 779
Reputation: 412
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()
Upvotes: 1