I have the follow attribute in a DynamoDB table (trust me, I know it's a mess):
"list1": [
{
"mapName": "map1",
"list2": [
{
"mapName": "map2",
"list3": [ #append map here
]
}
]
}
]
I need to append a map to list3, and I am struggling with the syntax of how to make update_item do this. The position in list1 and list2 are stored in variables i and j respectively. I am trying something like this:
table.update_item(
Key={
'primary_key': item_name
},
UpdateExpression="SET list1[:i].list2[:j].list3 = list_append(list1[:i].list2[:j].list3, :x)",
ExpressionAttributeValues={
':x': map,
':i': i,
':j': j
}
)
The error message I am getting with the code is at the update_item line:
"errorMessage": "An error occurred (ValidationException) when calling the UpdateItem operation: Invalid UpdateExpression: Syntax error; token: \":i\", near: \"[:i]\"",
I'm guessing I will need some combination of ExpressionAttributeNames and ExpressionAttributeValues, but I am not very familiar with boto3 syntax. Any help on how to accomplish this would be greatly appreciated.