Java 类com.amazonaws.services.dynamodbv2.document.DeleteItemOutcome 实例源码

项目:aws-dynamodb-examples    文件:DocumentAPIItemCRUDExample.java   
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());
        }
    }
项目:outland    文件:DefaultGroupStorage.java   
@Override
public Void removeRelation(Group group, String relationHashKey, String relationRangeKey) {

  Table table = dynamoDB.getTable(groupGraphTableName);

  final PrimaryKey key = new PrimaryKey(
      GroupStorage.SUBJECT_KEY, relationHashKey,
      GroupStorage.OBJECT_RELATION_KEY, relationRangeKey
  );

  DynamoDbCommand<DeleteItemOutcome> cmd = new DynamoDbCommand<>("removeRelation",
      () -> table.deleteItem(key),
      () -> {
        throw new RuntimeException("removeRelation");
      },
      dynamodbGraphWriteHystrix,
      metrics);

  final DeleteItemOutcome deleteItemOutcome = cmd.execute();

  logger.info("{} /dynamodb_remove_item_result=[{}]",
      kvp("op", "removeRelation",
          "appkey", group.getKey(),
          "hash_key", relationHashKey,
          "range_key", relationRangeKey,
          "result", "ok"),
      deleteItemOutcome.getDeleteItemResult().toString());

  return null;
}
项目:serverless    文件:BookDelete.java   
@Override
public String handleRequest(Book request, Context context) {

    DeleteItemOutcome outcome = DynamoDBUtil.getTable().deleteItem(new PrimaryKey("id", request.getId()));

    String result = "Item deleted: " + outcome.getDeleteItemResult().getSdkHttpMetadata().getHttpStatusCode();

    return result;
}