I am struggling with incrementing a number property value of an item already saved in my table on DynamoDB my code currently is:
AWSDynamoDBUpdateItemInput *updateItemInput = [AWSDynamoDBUpdateItemInput new];
updateItemInput.tableName = @"Table";
updateItemInput.key= @{
@"KeyPropertyName":@"KeyValue"
};
updateItemInput.updateExpression = @"SET(counter = counter + :val)";
updateItemInput.expressionAttributeValues =@{
@":val":@1
};
AWSDynamoDB *dynamoDB = [AWSDynamoDB defaultDynamoDB];
[[dynamoDB updateItem:updateItemInput]
continueWithBlock:^id(AWSTask *task) {
if (task.error) {
NSLog(@"The request failed. Error: [%@]", task.error);
}
if (task.exception) {
NSLog(@"The request failed. Exception: [%@]", task.exception);
}
if (task.result) {
//Do something with result.
}
return nil;
}];
My app always crashes when I do not comment out the updateExpression and expressionAttributeValues. I can reach the block when I create an empty instance of my item type and get strange results when I create an instance of AWSDynamoDBAttributeValue to pass in the key. Any suggestions? Am I also improperly writing my updateExpression?
I am also going to be adding updating and deleting items in array/list and dictionary/map properties on another object. How would this differ?