I'm working on a Node.js function that will make three concurrent calls to an Amazon DynamoDB: put (store some info), query (get some info), and update (conditionally update some info). The calls do not depend on each other.
Amazon's SDK can invoke them asynchronously using either callbacks:
var docClient = new AWS.DynamoDB.DocumentClient();
docClient.put(params1, callback);
docClient.query(params2, callback);
docClient.update(params3, callback);
or with promises:
var promise1 = docClient.put(params1).promise();
var promise2 = docClient.query(params2).promise();
var promise3 = docClient.update(params3).promise();
I want to process the results of the query call, but only after the other two calls have settled. I don't care in what order they happen, or if they are successful.
Promise.all() would do the trick, except for the fact that it is likely that the update will throw an exception (Amazon treats conditional updates that don't meet their condition as exceptions).
How would you solve this?