dynamoDB更新项目,获取ValidationException:提供的键元素与架构不匹配

时间:2019-03-18 16:52:46

标签: go amazon-dynamodb

我有以下代码:

func updateStatusInDynamoDB(svc dynamodbiface.DynamoDBAPI, tableName, bucketName, objectKey string) error {
    _, err := svc.UpdateItem(&dynamodb.UpdateItemInput{
        TableName: aws.String(tableName),
        Key: map[string]*dynamodb.AttributeValue{
            "data": &dynamodb.AttributeValue{
                M: map[string]*dynamodb.AttributeValue{
                    "original": &dynamodb.AttributeValue{S: aws.String(fmt.Sprintf("s3://%s/%s", bucketName, objectKey))},
                },
            },
        },
        UpdateExpression: aws.String("set job_status = :s"),
        ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
            ":s": &dynamodb.AttributeValue{S: aws.String(PROCESSED)},
        },
    })

    return err
}

我在dynamoDB中的输入如下:

{
  "data": {
    "original": "s3://api-prod-uploadbucket-***/uploads/www.domain.tld/provider/archive.csv"
  },
  "job_status": "UPLOADED",
  "provider": "provider",
  "timestamp": "2019-03-18 15:52:22.075817398 +0000 UTC m=+0.079862916",
  "uuid": "7c571c46-22a5-4137-acdf-9d6bcdf06abb",
  "website": "www.domain.tld"
}

但是我得到这个错误:

ValidationException: The provided key element does not match the schema

当我仅通过data.original时,选择记录的正确方法是什么?

非常感谢任何建议

0 个答案:

没有答案