Skip to main content
Version: 2.x

update

def update[From: Schema](tableName: String)(primaryKeyExpr: KeyConditionExpr.PrimaryKeyExpr[From])(
action: Action[From]
): DynamoDBQuery[From, Option[From]] = ???

The update operation is used to modify an existing item in a table. Both KeyConditionExpr.PrimaryKeyExpr and the Action params can be created using the ProjectionExpression's in the companion object for model class:

for {
_ <- DynamoDBQuery.update("person")(Person.id.primaryKey === "1")(
Person.name.set(42) + Person.age.set(42)
).execute
} yield maybePerson

update expressionsโ€‹

actiondescription
+combines update actions eg Person.name.set(42) + Person.age.set(42)
setSet an attribute Person.name.set("John")
setIfNotExistsSet attribute if it does not exists Person.name.setIfNotExists("John")
appendListAdd supplied list to the end of this list attribute
prependPrepend an element to a list attribute
prependListPrepend a list to list attribute
deleteFromSetdelete all elements that match the supplied set
add(a: To)adds this value as a number attribute if it does not exists, else adds the numeric value to the existing attribute
addSetAdds this set as an attribute if it does not exists, else if it exists it adds the elements of the set
remove(index: Int)remove an element at the specified index
removeRemoves this path expression from an item

See AWS API Reference to learn more about update expressions.

update query operationsโ€‹

<UPDATE_QUERY>
.returns(<ReturnValues>) // ReturnValues.AllNew | ReturnValues.AllOld | ReturnValues.None <default>
.where(<ConditionExpression>)

ZIO Chat

๐Ÿ”ฅ Ignite your ZIO journey with ZIO Chat! ๐Ÿ”ฅ Ready to unravel the intricacies of ZIO? As your trusty sidekick, I'm here to light the way. No matter if you're wandering through functional forests or traversing effectful landscapes, I've got answers to keep you on track. Your ZIO adventure starts here โ€“ ask me anything and let's explore together!