Refine search
@Override public UpdateItemOutcome updateItem(PrimaryKey primaryKey, String updateExpression, String conditionExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return updateItem(new UpdateItemSpec().withPrimaryKey(primaryKey) .withUpdateExpression(updateExpression) .withConditionExpression(conditionExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
@Override public UpdateItemOutcome updateItem(PrimaryKey primaryKey, Collection<Expected> expected, AttributeUpdate... attributeUpdates) { return updateItem(new UpdateItemSpec() .withPrimaryKey(primaryKey) .withExpected(expected) .withAttributeUpdate(attributeUpdates)); }
@Override public UpdateItemOutcome updateItem(PrimaryKey primaryKey, AttributeUpdate... attributeUpdates) { return updateItem(new UpdateItemSpec() .withPrimaryKey(primaryKey) .withAttributeUpdate(attributeUpdates)); }
/** * Convenient method to specify expressions (and the associated name map and * value map) via {@link UpdateItemExpressionSpec}. */ @Beta public UpdateItemSpec withExpressionSpec(UpdateItemExpressionSpec xspec) { return withUpdateExpression(xspec.getUpdateExpression()) .withConditionExpression(xspec.getConditionExpression()) .withNameMap(xspec.getNameMap()) .withValueMap(xspec.getValueMap()) ; } }
UpdateItemSpec updateItemSpec = new UpdateItemSpec(); ... updateItemSpec.withReturnValues(ReturnValue.ALL_NEW);
UpdateItemSpec updateItemSpec = new UpdateItemSpec() .withPrimaryKey("login_id", login_id) .withUpdateExpression("set isUserVerified = :val") .withValueMap(new ValueMap() .withBoolean(":val", true));
public UpdateItemSpec withExpected(Expected ... expected) { if (expected == null) { this.expected = null; return this; } return withExpected(Arrays.asList(expected)); }
@Override public UpdateItemOutcome updateItem(PrimaryKey primaryKey, AttributeUpdate... attributeUpdates) { return updateItem(new UpdateItemSpec() .withPrimaryKey(primaryKey) .withAttributeUpdate(attributeUpdates)); }
/** * Convenient method to specify expressions (and the associated name map and * value map) via {@link UpdateItemExpressionSpec}. */ @Beta public UpdateItemSpec withExpressionSpec(UpdateItemExpressionSpec xspec) { return withUpdateExpression(xspec.getUpdateExpression()) .withConditionExpression(xspec.getConditionExpression()) .withNameMap(xspec.getNameMap()) .withValueMap(xspec.getValueMap()) ; } }
val updateItemSpec:UpdateItemSpec = new UpdateItemSpec() .withPrimaryKey("hashkey", my_key) .withUpdateExpression("set my_list = list_append(:prepend_value, my_list)") .withValueMap(new ValueMap() .withList(":prepend_value", "1")) .withReturnValues(ReturnValue.UPDATED_NEW) println("Updating the item...") val outcome: UpdateItemOutcome = table.updateItem(updateItemSpec) println("UpdateItem succeeded:\n" + outcome.getItem.toJSONPretty)
public UpdateItemSpec withExpected(Expected ... expected) { if (expected == null) { this.expected = null; return this; } return withExpected(Arrays.asList(expected)); }
@Override public UpdateItemOutcome updateItem(PrimaryKey primaryKey, String updateExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return updateItem(new UpdateItemSpec() .withPrimaryKey(primaryKey) .withUpdateExpression(updateExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
@Override public UpdateItemOutcome updateItem(PrimaryKey primaryKey, Collection<Expected> expected, AttributeUpdate... attributeUpdates) { return updateItem(new UpdateItemSpec() .withPrimaryKey(primaryKey) .withExpected(expected) .withAttributeUpdate(attributeUpdates)); }
UpdateItemOutcome updateItemOutcome = table.updateItem( new UpdateItemSpec() .withPrimaryKey("id", "yourId") .withUpdateExpression("SET document.field = :field") .withValueMap(new ValueMap() .withMap(":field", "map of key value pairs that will get serialized to json")));
@Override public UpdateItemOutcome updateItem(PrimaryKey primaryKey, String updateExpression, String conditionExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return updateItem(new UpdateItemSpec().withPrimaryKey(primaryKey) .withUpdateExpression(updateExpression) .withConditionExpression(conditionExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
@Override public boolean replace(String key, String oldValue, String newValue) { Assert.hasText(key, "'key' must not be empty."); Assert.hasText(oldValue, "'value' must not be empty."); Assert.hasText(newValue, "'newValue' must not be empty."); awaitForActive(); UpdateItemSpec updateItemSpec = new UpdateItemSpec() .withPrimaryKey(KEY, key) .withAttributeUpdate( new AttributeUpdate(VALUE) .put(newValue)) .withExpected( new Expected(VALUE) .eq(oldValue)) .withReturnValues(ReturnValue.UPDATED_NEW); if (this.timeToLive != null && this.timeToLive > 0) { updateItemSpec = updateItemSpec.addAttributeUpdate( new AttributeUpdate(TTL) .put((System.currentTimeMillis() + this.timeToLive) / 1000)); } try { return this.table.updateItem(updateItemSpec) .getItem() != null; } catch (ConditionalCheckFailedException e) { return false; } }
UpdateItemSpec updateItemSpec = new UpdateItemSpec().withPrimaryKey("orderId", "75246c41-02c7-48c4-8d4c-d202483e6d2b") .withReturnValues(ReturnValue.ALL_NEW).withUpdateExpression("set #createDate = if_not_exists (#createDate, :val1)") .withNameMap(new NameMap().with("#createDate", "createDate")) .withValueMap(new ValueMap().withNumber(":val1", 1)); UpdateItemOutcome outcome = table.updateItem(updateItemSpec);
@Override public UpdateItemOutcome updateItem(PrimaryKey primaryKey, String updateExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return updateItem(new UpdateItemSpec() .withPrimaryKey(primaryKey) .withUpdateExpression(updateExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
@Override public boolean replace(String key, String oldValue, String newValue) { Assert.hasText(key, "'key' must not be empty."); Assert.hasText(oldValue, "'value' must not be empty."); Assert.hasText(newValue, "'newValue' must not be empty."); awaitForActive(); UpdateItemSpec updateItemSpec = new UpdateItemSpec() .withPrimaryKey(KEY, key) .withAttributeUpdate( new AttributeUpdate(VALUE) .put(newValue)) .withExpected( new Expected(VALUE) .eq(oldValue)) .withReturnValues(ReturnValue.UPDATED_NEW); if (this.timeToLive != null && this.timeToLive > 0) { updateItemSpec = updateItemSpec.addAttributeUpdate( new AttributeUpdate(TTL) .put((System.currentTimeMillis() + this.timeToLive) / 1000)); } try { return this.table.updateItem(updateItemSpec) .getItem() != null; } catch (ConditionalCheckFailedException e) { return false; } }
UpdateItemSpec updateItemSpec = new UpdateItemSpec().withPrimaryKey("yearkey", yearKey, "title", title) .withReturnValues(ReturnValue.UPDATED_NEW).withUpdateExpression("set #createdate = :val1") .withNameMap(new NameMap().with("#createdate", "createdate")) .withValueMap(new ValueMap().withString(":val1", createDate)) .withConditionExpression("createdate < :val1"); UpdateItemOutcome outcome = null; try { outcome = table.updateItem(updateItemSpec); } catch (ConditionalCheckFailedException ce) { System.out.println("Conditional check failed." + ce.getMessage()); return false; } return true;