Closed austinkelleher closed 4 years ago
This is super slick. I think this is probably better addressed by a transform rather than a change to the expression language, though, simply because others' use cases are likely to vary a lot on this. I'll 100% reconsider that if this gets overwhelming support!
Something like:
jexl.addTransform('mapTo', (collection, prop) => collection.map(elem => elem[prop]))
jexl.evalSync("data|mapTo('properties')", context)
This may already be supported, but if so, I couldn't find the syntax in the documentation. Currently, Jexl supports filtering using the
data[.name == 'Austin'].id
syntax. I'd like to be able to basicallymap
an array, so that we can return a subset of properties.Here are two examples of what I'm trying to accomplish:
Sample internal
map
functionality:Sample mapping of sub properties:
Thoughts @TomFrost?