Example usage for com.amazonaws.services.dynamodbv2.document Table updateItem

List of usage examples for com.amazonaws.services.dynamodbv2.document Table updateItem

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.document Table updateItem.

Prototype

@Beta
    public UpdateItemOutcome updateItem(String hashKeyName, Object hashKeyValue, String rangeKeyName,
            Object rangeKeyValue, UpdateItemExpressionSpec updateExpressions) 

Source Link

Usage

From source file:oxwodwebdriver.DynamoHelper.java

public static void UploadProcessedWodDataToDynamoDB(String wod, String cardText) {
    System.out.println("About to upload data to DynamoDB");

    BasicAWSCredentials awsCreds = new BasicAWSCredentials("", "");
    AmazonDynamoDBClient client = new AmazonDynamoDBClient(awsCreds).withRegion(Regions.US_EAST_1);
    DynamoDB dynamoDB = new DynamoDB(client);
    Table table = dynamoDB.getTable("OxWod");

    Map<String, String> expressionAttributeNames = new HashMap<String, String>();
    expressionAttributeNames.put("#W", "Wod");
    expressionAttributeNames.put("#C", "CardWod");

    Map<String, Object> expressionAttributeValues = new HashMap<String, Object>();
    expressionAttributeValues.put(":val1", wod);
    expressionAttributeValues.put(":val2", cardText);

    UpdateItemOutcome outcome = table.updateItem("Id", // key attribute name
            1, // key attribute value
            "set #W = :val1, #C = :val2", // UpdateExpression
            expressionAttributeNames, expressionAttributeValues);
    System.out.println("Fnished uploading data to DynamoDB");
}