.withExpressionAttributeNames( deleteExpression.getExpressionAttributeNames()) .withExpressionAttributeValues( deleteExpression.getExpressionAttributeValues());
private DeleteItemOutcome doDeleteItem(DeleteItemSpec spec) { // set the table name final String tableName = getTable().getTableName(); // set up the keys DeleteItemRequest req = spec.getRequest().withTableName(tableName) .withKey(InternalUtils.toAttributeValueMap(spec.getKeyComponents())); // set up the expected attribute map, if any final Collection<Expected> expected = spec.getExpected(); final Map<String, ExpectedAttributeValue> expectedMap = InternalUtils.toExpectedAttributeValueMap(expected); // set up the value map, if any (when expression API is used) final Map<String,AttributeValue> attrValMap = InternalUtils.fromSimpleMap(spec.getValueMap()); // set up the request req.withExpected(expectedMap) .withExpressionAttributeNames(spec.getNameMap()) .withExpressionAttributeValues(attrValMap) ; DeleteItemResult result = getClient().deleteItem(req); return new DeleteItemOutcome(result); }
.withExpressionAttributeNames( deleteExpression.getExpressionAttributeNames()) .withExpressionAttributeValues( deleteExpression.getExpressionAttributeValues());
private static void deleteItem() { try { HashMap<String, AttributeValue> key = new HashMap<String, AttributeValue>(); key.put("Id", new AttributeValue().withN("120")); Map<String, AttributeValue> expressionAttributeValues = new HashMap<String, AttributeValue>(); expressionAttributeValues.put(":val", new AttributeValue().withBOOL(false)); ReturnValue returnValues = ReturnValue.ALL_OLD; DeleteItemRequest deleteItemRequest = new DeleteItemRequest() .withTableName(tableName) .withKey(key) .withConditionExpression("InPublication = :val") .withExpressionAttributeValues(expressionAttributeValues) .withReturnValues(returnValues); DeleteItemResult result = client.deleteItem(deleteItemRequest); // Check the response. System.out.println("Printing item that was deleted..."); printItem(result.getAttributes()); } catch (AmazonServiceException ase) { System.err.println("Failed to get item after deletion " + tableName); } }
private Collection<MutateWorker> createWorkersForDeletions(final StaticBuffer hashKey, final List<StaticBuffer> deletions, final DynamoDbStoreTransaction txh) { final List<MutateWorker> workers = new LinkedList<>(); for (StaticBuffer rangeKey : deletions) { final Map<String, AttributeValue> keys = new ItemBuilder().hashKey(hashKey) .rangeKey(rangeKey) .build(); final Expression updateExpression = new MultiUpdateExpressionBuilder(this, txh).hashKey(hashKey) .rangeKey(rangeKey) .build(); final DeleteItemRequest request = super.createDeleteItemRequest().withKey(keys) .withConditionExpression(updateExpression.getConditionExpression()) .withExpressionAttributeValues(updateExpression.getAttributeValues()); workers.add(new DeleteItemWorker(request, client.getDelegate())); } return workers; }
.withExpressionAttributeNames( deleteExpression.getExpressionAttributeNames()) .withExpressionAttributeValues( deleteExpression.getExpressionAttributeValues());
private DeleteItemOutcome doDeleteItem(DeleteItemSpec spec) { // set the table name final String tableName = getTable().getTableName(); // set up the keys DeleteItemRequest req = spec.getRequest().withTableName(tableName) .withKey(InternalUtils.toAttributeValueMap(spec.getKeyComponents())); // set up the expected attribute map, if any final Collection<Expected> expected = spec.getExpected(); final Map<String, ExpectedAttributeValue> expectedMap = InternalUtils.toExpectedAttributeValueMap(expected); // set up the value map, if any (when expression API is used) final Map<String,AttributeValue> attrValMap = InternalUtils.fromSimpleMap(spec.getValueMap()); // set up the request req.withExpected(expectedMap) .withExpressionAttributeNames(spec.getNameMap()) .withExpressionAttributeValues(attrValMap) ; DeleteItemResult result = getClient().deleteItem(req); return new DeleteItemOutcome(result); }