0
是否可以运行针对亚马逊DynamoDB的请求的updateItem用,如果该项目不存在,将永远成功的条件存在。例如:如何通过条件检查,如果项目不与AWS DynamoDB的updateItem要求
long timestampNow = System.currentTimeMillis();
UpdateItemSpec updateItemSpec = new UpdateItemSpec()
.withPrimaryKey("primary_key", theKey)
.withReturnValues(ReturnValue.ALL_NEW)
.withAttributeUpdate(
new AttributeUpdate("my_attr").put(timestampNow+SOME_DURATION))
.withExpected(
new Expected("my_attr").lt(timestampNow));
try {
UpdateItemOutcome outcome = AWS.DYNAMO_DOC.getTable("my_table").updateItem(updateItemSpec);
return outcome.getUpdateItemResult().getAttributes();
} catch (ConditionalCheckFailedException e) {
return null;
}
当我做了的项目,目前还不存在请求时,它抛出ConditionalCheckFailedException
,但我想它通过条件测试,只是继续创建项目。那可能吗?