Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dyanmodb use arithmetic in update condition

I have a Dynamodb update expression and I would like to validate if a sum of fields values is greather than other value, something like this:

.withConditionExpression("#a + #b >= :myValue")

Like this Dynamodb returns an error. Is there a way to atomically validate that condition?

like image 405
Filipe Santana Avatar asked Apr 08 '26 11:04

Filipe Santana


1 Answers

According to AWS Docs on Expressions Operators And Functions Syntax

Operands of the comparison operation can be only primitive field names (CANNOT be arithmetical expressions as in your question).

Documentation says:

In [...Condition expression...], an operand can be the following:

  • A top-level attribute name, such as Id, Title, Description or ProductCategory

  • A document path that references a nested attribute

like image 198
Dimitry K Avatar answered Apr 21 '26 01:04

Dimitry K