In DynamoDB, is it possible to accomplish the following via an UpdateItem
operation?
set attributeA to valueX if the attribute does not exist
set attributeB to valueX if attributeA exists
Both of these must be in the same UpdateItem
operation. I'm aware of things like attribute_not_exists
and if_not_exists
, but I couldn't find an if_exists
condition.
How can I accomplish the above task using the low-level APIs?
CodePudding user response:
Sorry, you cannot in one UpdateItem
.
You can fetch the item, modify it on the client, then push a new copy. Use optimistic locking to ensure the item wasn't modified in between.