amazon-dynamodb - 未能在 DynamoDB 中设置 LIST 值
问题描述
我正在尝试在我的 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 添加单个条目,但我需要设置整个列表...我做错了什么?
是否可以在单个查询中设置整个表?
提前致谢
解决方案
原来缺少值的类型。这是正确的结构:
{
"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"
}
推荐阅读
- python - 具有多个参数的 Python 函数
- c++ - 私有成员数据不可用于公共成员函数
- javascript - JS:按数组过滤对象数组,当对象键是对象数组时
- android - FileReader 无法从相机读取文件 - Xamarin + WebView
- qt4 - 如何在alpine 3.12中安装qt4
- python - 为什么我的熊猫数据框只占用第一列和最后一列?
- sql - Azure 应用服务无法连接到 Azure SQL 数据库
- javascript - React / Redux:未处理的拒绝(TypeError):无法读取未定义的属性“数据”
- javascript - 如何使用 Javascript 在填字游戏网格中添加导航功能?
- python - 在 pandas 中使用 pd.get_dummies 转换有和没有唯一分隔符的分类特征