List of usage examples for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient updateItem
@Override
public UpdateItemResult updateItem(UpdateItemRequest request)
Edits an existing item's attributes, or adds a new item to the table if it does not already exist.
From source file:awslabs.lab22.SolutionCode.java
License:Open Source License
@Override public void updateIfMatch(AmazonDynamoDBClient ddbClient, String tableName, String email, String company, String firstNameTarget, String firstNameMatch) { // Construct an UpdateItemRequest object for the specified table. UpdateItemRequest updateItemRequest = new UpdateItemRequest().withTableName(tableName); // Add KeyEntry elements to the request containing AttributeValue objects for the company name and email // address provided. updateItemRequest.addKeyEntry("Company", new AttributeValue().withS(company)); updateItemRequest.addKeyEntry("Email", new AttributeValue().withS(email)); // Add an ExpectedEntry element to the request containing an ExpectedAttributeValue object that contains // the value in the firstNameMatch parameter. updateItemRequest.addExpectedEntry("First", new ExpectedAttributeValue().withValue(new AttributeValue().withS(firstNameMatch))); // Add an AttributeUpdatesEntry element to the request containing an AttributeValueUpdate object that // contains the value in the firstNameTarget parameter updateItemRequest.addAttributeUpdatesEntry("First", new AttributeValueUpdate().withAction("PUT") .withValue(new AttributeValue().withS(firstNameTarget))); // Submit the request using the updateItem method of the ddbClient object. ddbClient.updateItem(updateItemRequest); }