Expressions (conditions, update)

For conditions and updates, DynamoDB uses expression statements. We provide functions to build those expressions either in a strictly or a non-typed way.

technical api doc

Condition

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html

Condition Expressions are used for two purposes:

  • pre condition for write operations (delete, put, update) onlyIf(),onlyIfAttribute()

  • filter condition for read operations (query, scan ) where(),whereAttribute()

onlyIfAttribute() and whereAttribute() provide a chainable way to add your conditions, all conditions are combined with and operator:

to either use not or or operator you need to use the onlyIf() resp. where()methods:

For better typings the attribute2 function is provided (only useful for top level properties)

circle-info

The same methods also exists for all transact operations (used in TransactWriteRequest)

Update

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html

As for condition expressions, there are two ways to define the update expressions for an update request:

the chainable way:

the not-that-chainy way:

the operations method primarily exists for more flexibility

There also exists the update2(ModelClazz, propertyName) function as equivalent to attribute2() for better typing.

circle-info

The same methods also exists for TransactUpdate (used in TransactWriteRequest)

Last updated

Was this helpful?