Is it possible to combine if_not_exists and list_append in update_item

后端 未结 2 1480
天命终不由人
天命终不由人 2020-12-05 01:22

I\'m trying to use the update_item functionality for DynamoDB in boto3.

I\'m struggling right now to update lists for items. I would like to create a n

2条回答
  •  醉话见心
    2020-12-05 01:51

    You can use list_append(if_not_exists()) construction.

    UpdateExpression:

    'SET my_list2 = list_append(if_not_exists(my_list2, :empty_list), :my_value)'
    

    ExpressionAttributeValues:

    { ":my_value":[{"S":"test"}], ":empty_list":{"L":[]} }
    

提交回复
热议问题