I’m using the AWS Java SDK v2 with UpdateExpression so that I can update an item without having to retrieve the item from DynamoDB.
I’ve managed to build the update expression but now I don’t know how to action it.
DynamoDbEnhancedClient client = DynamoDbEnhancedClient.builder()
.dynamoDbClient(DynamoDbClient.builder().region(Region.EU_WEST_1).build())
.extensions(AutoGeneratedUuidExtension.create())
.build();
DynamoDbTable<MyClass> table = client.table("MyTable", TableSchema.fromBean(MyClass.clazz));
SetAction action = SetAction.builder()
.path("#optIn")
.value("if_not_exists(#optIn,:optInValue)")
.putExpressionValue(":optInValue", fromBool(true))
.build();
UpdateExpression updateExpression = UpdateExpression.builder()
.addAction(action)
.build();
// Now I don't know how to call table.execute(updateExpression, uniqueId);