【发布时间】:2021-08-11 08:38:35
【问题描述】:
我正在尝试将值附加到 DynamoDB 表条目:
{
"id": "1",
"history": [
"638380895-8"
],
"currentbooks": "",
"email": "ocomford0@craigslist.org",
"name": "Osborne Comford"
}
我正在尝试编写代码以将字符串条目添加到“历史”数组。
以下是我的python代码:
usersTable = dynamodb.Table("users")
booksTable = dynamodb.Table("books")
bookisbn = event['isbn']
response = usersTable.update_item(
Key={
'id': userid,
},
UpdateExpression="set history=list_append(history, :s)",
ExpressionAttributeValues={
':s': bookisbn
},
ReturnValues="UPDATED_NEW"
)
它给了我错误:
"errorMessage": "An error occurred (ValidationException) when calling the UpdateItem operation: Invalid UpdateExpression: Incorrect operand type for operator or function; operator or function: list_append, operand type: S"
【问题讨论】:
标签: python amazon-web-services aws-lambda amazon-dynamodb