Update
Modifies an existing item. Pass the full key as keyword arguments, then use the 5 update actions.
Update Actions
| Action | Description | DynamoDB clause |
|---|---|---|
set | Set attribute values | SET #attr = :val |
remove | Remove attributes | REMOVE #attr |
append | Append to a list | SET #attr = list_append(#attr, :val) |
add | Increment number or add to set | ADD #attr :val |
delete | Remove elements from a set | DELETE #attr :val |
Basic Usage
orders.update(
user_id="usr_123", order_id="ord_789",
set={"status": "SHIPPED", "shipped_at": "2025-02-24"},
remove=["temp_notes"],
append={"history": {"action": "shipped", "at": "2025-02-24"}},
add={"version": 1, "tags": {"urgent"}},
delete={"old_tags": {"deprecated"}},
)
Nested Paths
Nested paths work in set:
orders.update(
user_id="usr_123", order_id="ord_456",
set={"address.city": "Lima", "items[0].qty": 5},
)
Multiple actions can be combined in a single update() call.