SimpleDBのテーブル内の全データを取得する方法

以下で取得できるようになります。

Promiseを使うことでシンプルにかけます。

process.env.TZ = "Asia/Tokyo";
var AWS = require('aws-sdk');
AWS.config.update({
    region: 'ap-northeast-1'
});

var simpledb = new AWS.SimpleDB({apiVersion: '2009-04-15', region: 'ap-northeast-1'});

var domainName = 'your_domain_name';

getAllItems().then(function(data) {
    console.log(JSON.stringify(data));
});

function getAllItems() {
    var dataList = [];
    var params = {
        SelectExpression: 'SELECT * FROM `' + domainName + '`',
        ConsistentRead: true,
        NextToken: null
    };

    function recursiveCall(params, resolve, reject) {
        simpledb.select(params, function(err, data) {
            if (err) {
                reject(err);
            } else {
                dataList = dataList.concat(data.Items);
                if (data.NextToken) {
                    params.NextToken = data.NextToken;
                    recursiveCall(params, resolve, reject);
                } else {
                    resolve(dataList);
                }
            }
        });
    }

    return new Promise(function(resolve, reject) {
        recursiveCall(params, resolve, reject);
    });
}

参考

http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SimpleDB.html#select-property

Promiseを使って再帰的に全データを取得する方法

http://stackoverflow.com/questions/35814198/recursively-calling-asynchronous-function-that-returns-a-promise

http://stackoverflow.com/questions/35139145/retrieve-paginated-data-recursively-using-promises