gpt4 book ai didi

javascript - 从 GSI 获取项目但得到 "The provided key element does not match the schema"

转载 作者:行者123 更新时间:2023-12-02 22:10:24 25 4
gpt4 key购买 nike

我的 AWS DynamoDB 表在最后一列包含 ref1、ref2 和 ref3,如下所示 columns

这里是概述 overview

我正在尝试get a record在 AWS DynamoDB 中,使用 ref1、ref2 和 ref3 作为组合键 GSI

  params = {
TableName: process.env.PAYMENT_DB_TRANSACTION,
Key: {
"ref1": billPaymentRef1,
"ref2": billPaymentRef2,
"ref3": billPaymentRef3
}
};
console.log(params);
docClient.get(params, function(err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
}
});

我确认params正确

{
TableName: 'payment-th-stg-v2-op-transaction',
Key: { ref1: 'REF1', ref2: 'REF2', ref3: 'REF3' }
}

这是错误

Unable to read item. Error JSON: {
"message": "The provided key element does not match the schema",
"code": "ValidationException",
"time": "2020-01-03T12:17:39.090Z",
"requestId": "PDC6A7N22Q8BT789H3K2I1N9VNVV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 48.839609039271245
}

问题:
我哪里错了?

最佳答案

您必须使用主键查询项目,在您的情况下,主键是分区键 + 排序键:requestId + CountryCode。

关于javascript - 从 GSI 获取项目但得到 "The provided key element does not match the schema",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59578600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com