Search in sources :

Example 1 with DeleteItemOutcome

use of com.amazonaws.services.dynamodbv2.document.DeleteItemOutcome in project aws-doc-sdk-examples by awsdocs.

the class DocumentAPIItemCRUDExample method deleteItem.

private static void deleteItem() {
    Table table = dynamoDB.getTable(tableName);
    try {
        DeleteItemSpec deleteItemSpec = new DeleteItemSpec().withPrimaryKey("Id", 120).withConditionExpression("#ip = :val").withNameMap(new NameMap().with("#ip", "InPublication")).withValueMap(new ValueMap().withBoolean(":val", false)).withReturnValues(ReturnValue.ALL_OLD);
        DeleteItemOutcome outcome = table.deleteItem(deleteItemSpec);
        // Check the response.
        System.out.println("Printing item that was deleted...");
        System.out.println(outcome.getItem().toJSONPretty());
    } catch (Exception e) {
        System.err.println("Error deleting item in " + tableName);
        System.err.println(e.getMessage());
    }
}
Also used : DeleteItemOutcome(com.amazonaws.services.dynamodbv2.document.DeleteItemOutcome) DeleteItemSpec(com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec) Table(com.amazonaws.services.dynamodbv2.document.Table) ValueMap(com.amazonaws.services.dynamodbv2.document.utils.ValueMap) NameMap(com.amazonaws.services.dynamodbv2.document.utils.NameMap) IOException(java.io.IOException)

Aggregations

DeleteItemOutcome (com.amazonaws.services.dynamodbv2.document.DeleteItemOutcome)1 Table (com.amazonaws.services.dynamodbv2.document.Table)1 DeleteItemSpec (com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec)1 NameMap (com.amazonaws.services.dynamodbv2.document.utils.NameMap)1 ValueMap (com.amazonaws.services.dynamodbv2.document.utils.ValueMap)1 IOException (java.io.IOException)1