Boto3 DynamoDB更新项目的列表属性 [英] Boto3 DynamoDB update list attributes for an item
问题描述
我有一张桌子,像这样:
{"pKey":10001,项目": [{"name":"A",值":100},{"name":"B",值":100}]}
我想将 items
列表中的所有 value
属性更新为200, items
列表中可以包含1到n个对象.>
如何使用boto3 python dynamoDB低级客户端API做到这一点?
我还没有真正测试过,但这就是我可以通过阅读 I would like to update all How can I do that using boto3 python dynamoDB low-level client APIs? I haven't really tested this but this is what I can come up just by reading the docs:
这篇关于Boto3 DynamoDB更新项目的列表属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!value
attributes in items
list to be 200, items
list can have 1 to n objects.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')