Reputation: 46
I have a table like:
{
"pKey": 10001,
"items": [
{
"name": "A",
"value": 100
},
{
"name": "B",
"value": 100
}
]
}
I would like to update all value
attributes in items
list to be 200, items
list can have 1 to n objects.
How can I do that using boto3 python dynamoDB low-level client APIs?
Upvotes: 0
Views: 2361
Reputation: 26281
I haven't really tested this but this is what I can come up just by reading the docs:
import boto3
ddb = boto3.resource('dynamodb')
table = ddb.Table('your_table')
document = table.get_item(Key={'pKey': 10001})['Item']
for item in document['items']:
item['value'] = 200
table.put_item(Item=document, ReturnValues='NONE')
Upvotes: 3