use of com.amazonaws.services.dynamodbv2.document.utils.NameMap in project aws-doc-sdk-examples by awsdocs.
the class DocumentAPIItemCRUDExample method updateAddNewAttribute.
private static void updateAddNewAttribute() {
Table table = dynamoDB.getTable(tableName);
try {
UpdateItemSpec updateItemSpec = new UpdateItemSpec().withPrimaryKey("Id", 121).withUpdateExpression("set #na = :val1").withNameMap(new NameMap().with("#na", "NewAttribute")).withValueMap(new ValueMap().withString(":val1", "Some value")).withReturnValues(ReturnValue.ALL_NEW);
UpdateItemOutcome outcome = table.updateItem(updateItemSpec);
// Check the response.
System.out.println("Printing item after adding new attribute...");
System.out.println(outcome.getItem().toJSONPretty());
} catch (Exception e) {
System.err.println("Failed to add new attribute in " + tableName);
System.err.println(e.getMessage());
}
}
Aggregations