Hello,
I am learning lambda function. I am using nodejs16.x runtime and aws-sdk to perform CRUD operation in dynamodb tables. I am using aws management console to this. I created a table in dynamodb the table has partition key as id then i inserted an item into it that looks like this {"id" : {S : "someid"}, "views" : {N : "0"}} . Now using lambda function I am updating this item's view property; for that I am incrementing the views by 1. after running the function the returned object is correct and show the new values of views for that item as 1. But when I open the dynamodb console and see the table, the views property value is not 1 but 2. And therefore on 2nd execution --> return {views : 3} where as this should be 2 but in dynamodb console the value is now at 4.
lambda function
Dynamodb Table
executing lambda function
dyamodb table item -- now view should be 1 but it shows 2
first decouple the variable like this,