DynamoDB的updateItem操作失败

3

尝试创建一个Lambda函数,从Kinesis流更新DynamoDB。这是我的更新语句:

var response = dd.updateItem({
            'Key': {'S': payload.identityId},
            'TableName': 'Users',
            'UpdateExpression': 'SET testVal = :testVal',
            'ExpressionAttributeValues': {
                ':testVal': {'S': 'This is a test'}
           }
}

这会生成47个错误消息:

  • InvalidParameterType:预期params.Key [ 'S' ]为结构体

  • UnexpectedParameter:在params.Key [ 'S' ]中找到意外的键'0'

  • UnexpectedParameter:在params.Key [ 'S' ]中找到意外的键'1'
  • UnexpectedParameter:在params.Key [ 'S' ]中找到意外的键'2'
  • UnexpectedParameter:在params.Key [ 'S' ]中找到意外的键'3'

...

  • UnexpectedParameter:在params.Key [ 'S' ]中找到意外的键'44'
  • UnexpectedParameter:在params.Key [ 'S' ]中找到意外的键'45'

Users表已存在且当前为空。我已经双重检查了identityID是否存在(并且有效)。有人能看出我在这里做错了什么吗?

1个回答

6

我搞定了,有时候提出问题可以让你以不同的方式思考它!

我没有正确传递 Key

dd.updateItem({
            'Key': {
                'hashAttributeName': {
                    'S': payload.identityId
                }
            },
            'TableName': 'Users',
            'UpdateExpression': 'SET testVal = :testVal',
            'ExpressionAttributeValues': {
                ':testVal': {'S': 'This is a test'}
            }
        }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接