当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - DynamoDB: Decrement/Subtract a key/value

问题描述:

I have a key of type Number in a DynamoDB table. I set action as ADD to add a value to the existing value.

DynamoDBAttributeValue *attr =

[[[DynamoDBAttributeValue alloc] initWithN:@"1"] autorelease];

DynamoDBAttributeValueUpdate *attrUpdate =

[[DynamoDBAttributeValueUpdate alloc] initWithValue:attr andAction:@"ADD"];

Now, how do I subtract some value from the key?

网友答案:

You can set initWithN:@"-1" to substract 1 (or any value) from the attribute when using the ADD action.

I think you've misused the word key. Keys are immutable - only attributes can be updated.

分享给朋友:
您可能感兴趣的文章:
随机阅读: