gpt4 book ai didi

node.js - DynamoDB 扫描遗漏了有效项目

转载 作者:搜寻专家 更新时间:2023-11-01 00:28:44 24 4
gpt4 key购买 nike

在 DynamoDB 表中,我有一个具有以下方案的项目:

{
id: 427,
type: 'page',
...other_data
}

查询主索引 (id) 时,我按预期返回了项目。

通过在 AWS DynamoDB 网络应用程序中执行扫描操作以获取类型为page 的所有项目,返回了 188 个项目,包括这个缺失的项目。但是,使用 AWS SDK 在 Lambda 内部执行此扫描操作时,仅返回 162 个项目。部分代码如下所示:

const params = { 
TableName: <my-table-name>,
FilterExpression: '#type = :type',
ExpressionAttributeNames: { '#type': 'type' },
ExpressionAttributeValues: { ':type': 'page' }
};

dynamodb.scan(params, (error, result) => {
if (error) {
console.log('error', error);
} else {
console.log(result.Items); // 162 items
}
});

这里缺少什么?

最佳答案

这可能是您的结果数据集超过限制 1MB 的情况:

If the total number of scanned items exceeds the maximum data set size limit of 1 MB, the scan stops and results are returned to the user as a LastEvaluatedKey value to continue the scan in a subsequent operation. The results also include the number of items exceeding the limit. A scan can result in no table data meeting the filter criteria.

检查 LastEvaluatedKey 字段的结果并将其用于下一次扫描操作,将其作为 ExclusiveStartKey

关于node.js - DynamoDB 扫描遗漏了有效项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46926237/

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