问题
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
And if I'm calling the same query without any limit through cli, getting full response.
Not getting what's the problem.
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);
});
回答1:
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();
},
来源:https://stackoverflow.com/questions/52554652/facing-issue-scan-dynamo-db