Async pagination callback in JS driver

Hi guys

When using the JS driver it’d be great if the each method supported an asynchronous callback.

This would be really helpful when working with other services. One example is if we wanted to push docs into a queue that meet a certain criteria. We’d want to fetch all docs from an index, on each page iterate over the results and make a request to AWS SQS with the ID or something. An example of this in action could be:

const helper = client.paginate(q.Match(q.Index('test_index'), 'example-term'))

await helper.each(async (page) => {
   await Promise.all( => {
      return asyncPushToQueue(doc)

Currently .each only supports a synchronous function, so if we want to make use of the pagination helper we’d have to push promises into an array or something, which feels a little dirty. Alternatively we forgo the helper which is also doable, but it’d be nice to continue using the help that’s there.