我试图像这样在DynamoDB表中设置一个列表值:
{
"TableName": "my-table",
"Key": {
"uid": {
"S": "id-value"
}
},
"UpdateExpression": " SET #actions = :actions",
"ExpressionAttributeNames": {
"#actions": "actions"
},
"ExpressionAttributeValues": {
":actions": {
"L": [
"one",
"two"
]
}
},
"ReturnValues": "ALL_NEW"
}
运行此命令时,出现以下错误:
{
"message": "There were 8 validation errors:\n* InvalidParameterType: Expected params.ExpressionAttributeValues[':actions'].L[0] to be a structure\n* UnexpectedParameter: Unexpected key '0' found in params.ExpressionAttributeValues[':actions'].L[0]\n* UnexpectedParameter: Unexpected key '1' found in params.ExpressionAttributeValues[':actions'].L[0]\n* UnexpectedParameter: Unexpected key '2' found in params.ExpressionAttributeValues[':actions'].L[0]\n* InvalidParameterType: Expected params.ExpressionAttributeValues[':actions'].L[1] to be a structure\n* UnexpectedParameter: Unexpected key '0' found in params.ExpressionAttributeValues[':actions'].L[1]\n* UnexpectedParameter: Unexpected key '1' found in params.ExpressionAttributeValues[':actions'].L[1]\n* UnexpectedParameter: Unexpected key '2' found in params.ExpressionAttributeValues[':actions'].L[1]",
"code": "MultipleValidationErrors",
"errors": [
{
"message": "Expected params.ExpressionAttributeValues[':actions'].L[0] to be a structure",
"code": "InvalidParameterType",
"time": "2018-12-19T15:21:49.307Z"
},
{
"message": "Unexpected key '0' found in params.ExpressionAttributeValues[':actions'].L[0]",
"code": "UnexpectedParameter",
"time": "2018-12-19T15:21:49.307Z"
},
{
"message": "Unexpected key '1' found in params.ExpressionAttributeValues[':actions'].L[0]",
"code": "UnexpectedParameter",
"time": "2018-12-19T15:21:49.307Z"
},
{
"message": "Unexpected key '2' found in params.ExpressionAttributeValues[':actions'].L[0]",
"code": "UnexpectedParameter",
"time": "2018-12-19T15:21:49.307Z"
},
{
"message": "Expected params.ExpressionAttributeValues[':actions'].L[1] to be a structure",
"code": "InvalidParameterType",
"time": "2018-12-19T15:21:49.307Z"
},
{
"message": "Unexpected key '0' found in params.ExpressionAttributeValues[':actions'].L[1]",
"code": "UnexpectedParameter",
"time": "2018-12-19T15:21:49.307Z"
},
{
"message": "Unexpected key '1' found in params.ExpressionAttributeValues[':actions'].L[1]",
"code": "UnexpectedParameter",
"time": "2018-12-19T15:21:49.307Z"
},
{
"message": "Unexpected key '2' found in params.ExpressionAttributeValues[':actions'].L[1]",
"code": "UnexpectedParameter",
"time": "2018-12-19T15:21:49.307Z"
}
],
"time": "2018-12-19T15:21:49.308Z"
}
我知道可以使用list_append添加单个条目,但是我需要设置整个列表... 我在做什么错了?
是否可以在单个查询中设置整个表?
预先感谢
答案 0 :(得分:0)
结果是,缺少值的类型。 这是正确的结构:
{
"TableName": "my-table",
"Key": {
"uid": {
"S": "id-value"
}
},
"UpdateExpression": " SET #actions = :actions",
"ExpressionAttributeNames": {
"#actions": "actions"
},
"ExpressionAttributeValues": {
":actions": {
"L": [
{
"S": "one"
},
{
"S": "two"
}
]
}
},
"ReturnValues": "ALL_NEW"
}