-1

i am trying to check if key exist on table before making putItem operation on dynamodb to prevent overriding existing key value

Vijay Babu
  • 33
  • 8

1 Answers1

1
PutItemExpressionSpec PUT_ITEM_EXPRESSION_SPEC = new ExpressionSpecBuilder()
           .withCondition(ExpressionSpecBuilder.S("uuid").notExists())
           .buildForPut();

// create item

PutItemSpec putItemSpec = new PutItemSpec()
                .withItem(item)
                .withExpressionSpec(PUT_ITEM_EXPRESSION_SPEC); // Checking if UUID exists on the Table
// get Table
table.putItem(putItemSpec);
Vijay Babu
  • 33
  • 8