I would like my UpdateItem function to add the new value to the previous one but I can't figure out how to use numbers for the calculation and access the current value to be added to the new one.
Here is my working function, what I want to do is included in comment. How can I do it?
{
"TableName": "Votes",
"Key": {
"votesId": {
"S": "$input.path('$.votesId')"
}
},
"UpdateExpression": "set buy = :val1",
"ExpressionAttributeValues" : {
":val1": {
"N": "$input.path('$.buy')"
//Would like: "N": "buy + $input.path('$.buy')"
}
},
"ReturnValues": "ALL_NEW"
}
Here is how I test it:
{
"votesId":1,
"down":0,
"up":0,
"hold":0,
"buy":0,
"sell":0
}
You can use UpdateExpression to indicate which attributes are to be updated and what actions to perform.
Specifically in your case, UpdateExpression supports the following:
SET myNum = myNum + :val
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With