如何使递归dynamodb函数更短

时间:2019-07-09 21:47:24

标签: javascript typescript recursion amazon-dynamodb

嗨,我有几个在Angular中运行的递归动态查询,问题是我想使用数据数组来使10个具有不同名称的查询同时运行它们并列并连接在一起。例子

http://localhost:4569/https://someotherAPI.com/computer/update/multi

我现在要做的是创建10个这样的查询,并在此处同时运行它们,这是一个示例,并带有3个示例,因此更易于阅读

async getAllBooksSmith() {
//get all books from Publisher  SmithBooks for year 2019
let startkey: any;

let params = {
    TableName: 'books',
    IndexName: 'bookspubindex',
    KeyConditionExpression: '#key = :pbs and #sortkey = :rly',
    ExpressionAttributeValues: {
        ':pbs': 'SmithBooks',
        ':rly': '2019',
    },
    ExpressionAttributeNames: {
        '#key': 'Publisher',
        '#sortkey': 'ReleaseYear'
    },
    ExclusiveStartKey: startkey
}

let items = [];

while (true) {
    const db = await this.getDC();
    const data = await (db as DocumentClient).query(params).promise();
    items = items.concat(data.Items);

    if (!data.LastEvaluatedKey) {
        break;
    }

    params.ExclusiveStartKey = data.LastEvaluatedKey;
}

return items;

};

希望我解释了我想对像arr = ['SmithBooks','LowenBooks','ToysBooks']这样的数组做什么

0 个答案:

没有答案