redjack/bertha — pull request #4 by lwhorton (2014-10-07 17:12:38+00:00)
Title: Each support

When porting the vulnerabilities-list fetcher to use Bertha, we came
across the need to run another, separate execution plan across the
results of the first execution plan.

```javascript
var nextStep = {
typeA: {
paths: ['rj:a-types']
}
, typeB: {
paths: ['rj:b-types']
}
}

var plan = {
collection: {
root: '/api/'
, paths: ['rj:collections']
, each: [nextStep]
}
}

bertha.execute(plan).then(function (results) {
this.As = results.collection.memento[0].typeA.memento
this.Bs = results.collection.memento[0].typeB.memento
})
```

You can declare as many 'each' plans as you want, just list them out (in
order) inside the root plan. In this sense, the API traversals
essentially become data transformations across the results of API
endpoints.