Skip to content

Instantly share code, notes, and snippets.

@supun19
Created May 7, 2018 14:20
Show Gist options
  • Save supun19/c12d83f68d78c5cfdd1eb321eb8a83aa to your computer and use it in GitHub Desktop.
Save supun19/c12d83f68d78c5cfdd1eb321eb8a83aa to your computer and use it in GitHub Desktop.
Table table = dynamoDB.getTable("Table Name");
Map<String, String> consultee = new HashMap<>();
UpdateItemSpec updateItemSpec = new UpdateItemSpec().withPrimaryKey("eventId",eventId)
.withUpdateExpression("set #consultees = list_append(if_not_exists(consultees, :empty_consultees), :consultees) , #url = :url")
.withNameMap(new NameMap().with("#consultees", "consultees").with("#url","url"))
.withValueMap(new ValueMap().withList(":consultees", Arrays.asList(consultee)).withList(":empty_consultees", Arrays.asList()).withString(":url",url)).withReturnValues(ReturnValue.ALL_NEW);
UpdateItemOutcome outcome = table.updateItem(updateItemSpec);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment