面临的问题:扫描dynamo DB [英] Facing issue: scan dynamo DB
本文介绍了面临的问题:扫描dynamo DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在nodejs中创建了api,以扫描和查询dynamoDB表(包含7万条记录)。
我被扫描API困扰。我有两个用于扫描的API-
1.扫描表的限制为500-得到正确的响应
2.扫描表没有任何限制-响应码403
I've created apis in nodejs to scan and query dynamoDB table(contains 70K records). I'm stuck with scan api. I've two APIs for scan - 1. Scanning table with limit of 500 - getting proper response 2. Scanning table without any limit - response code 403
如果我通过cli无限制地调用相同的查询,则会得到完整的响应。
And if I'm calling the same query without any limit through cli, getting full response.
没有得到什么问题。
api.get('/deviceData', function (request) { // GET all users
return dynamoDb.scan({
TableName: 'student',
Limit: 500
}).promise()
.then(response => response.Items);
});
api.get('/deviceData-scan', function (request) { // GET all users
return dynamoDb.scan({
TableName: 'student'
}).promise()
.then(response => response.Items);
});
推荐答案
请检查如何使用扫描
多次
它可以帮助您。
Please check how to use scan
multiple time
its help you.
function getData() {
let params = {
TableName: 'student'
};
let finalResult = [];
let queryExecute = function () {
documentClient.scan(params, function (err, result) {
if (err) {
console.log('failure', err);
} else {
finalResult = finalResult.concat(result.Items);
// check if more data exists.
if (result.LastEvaluatedKey) {
params.ExclusiveStartKey = result.LastEvaluatedKey;
queryExecute();
} else {
console.log('all data', finalResult);
}
}
});
};
queryExecute();
},
这篇关于面临的问题:扫描dynamo DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文