Update NoSQL Items in Table
Catalyst enables you to update items in a specific NoSQL table after you construct them. An item can be updated by identifying it using its primary keys. For instance, you can use just the partition key or a combination of the partition key and sort key to identify the item.
You can then define the update operation type with the appropriate HTTP request method and provide the attributes and values to be updated in the item.
The example below illustrates this by retrieving an item with the partition key fruitName and the sort key location. The attributes of this item to be updated are color and taste. The values for all these attributes are provided.
You can also optionally define a condition for update. The update will occur only if the condition is met.
copy# Update a NoSQL item by identifying it with its primary keys res = table.update_items({ "keys": { "fruitName": { "S": "Banana" }, "location": { "S": "Indonesia" } }, # Define the attributes to be updated in the item "update_attributes": [ { "operation_type": "PUT", "color": { "S": "Yellow" }, "taste": { "S": "Sweet" }, "attribute_path": "fruitProperties" } ], # Define a condition. The item will be updated only if this is satisfied. (optional) "condition" : { "function": { "function_name": "attribute_exists", "args": [ { "attribute_path": "fruitProperties" } ] } } }) print(res)
Last Updated 2025-06-20 16:21:48 +0530 +0530
Yes
No
Send your feedback to us