DynamoDB increment a key/value

DynamoDB supports the concept of atomic counters. You would simply call update_item with action: "ADD" to automatically increment the value for an item.


As others have stated, you can increment with one operation, however "action: ADD" is now deprecated. The current way to achieve this is with UpdateExpression. I am also assuming the OP meant that there was a numeric [attribute] whose value needs incrementing. I am calling the attribute loginCount:

dynamoDB.updateItem({
  TableName: "Users",
  Key: { "UserId": { S: "c6af9ac6-7b61" } },
  ExpressionAttributeValues: { ":inc": {N: "1"} },
  UpdateExpression: "ADD loginCount :inc"
})