I want to save an element if the field either does not exist or is less than the given value.
So, the first time an item is written, this field will not exist. and in subsequent entries, it should be less than the set value.
However, it DynamoDBSaveExpressiondoes not seem to allow multiple conditions for the column. My current code is as follows:
Map<String, ExpectedAttributeValue> expected = new HashMap<>();
expected.put("lastProcessTime", new ExpectedAttributeValue().withComparisonOperator(ComparisonOperator.LT).withValue(
new AttributeValue().withN(String.valueOf(processTime))
));
DynamoDBSaveExpression saveExpression = new DynamoDBSaveExpression()
.withExpected(expected);
dynamoDBMapper.save(item, saveExpression);
However, this does not work if the table does not have an existing element with the same primary key, since in this case the value lastProcessTimeis equal null.
How do I achieve what I need?