我有一个表格列#34;名称"和"投票",每当我执行update_item时,我想增加投票数。我尝试了下面的查询,但没有运气。
{{moment-format model.date_of_birth 'DD/MM/YYYY' }}
将错误视为:
"调用UpdateItem时发生错误(ValidationException) 操作:无效的UpdateExpression:错误的操作数类型 操作员或功能; operator:ADD,operand type:MAP"
答案 0 :(得分:1)
请尝试以下更新。它应该解决问题。
db.update_item(Key={ "Name":"Dany"},
UpdateExpression='SET #oldVote = #oldVote + :newVote',
ExpressionAttributeNames={ '#oldVote' :'Vote'},
ExpressionAttributeValues={':newVote': 1}
)
答案 1 :(得分:0)
您可以尝试以下方法:
db.update_item(Key={ "Name":"Dany"},
UpdateExpression='SET Vote = Vote + :incr',
ExpressionAttributeValues={':incr': {"N": "1"}}
)