discovery
discovery copied to clipboard
How to search across all data paths?
Hi!
Let's say I have the following JSON data object inside struct view
foo: { bar: { items: [1, 2, 3, 4, 5] } }
Can I somehow force jora to search for 'items' key without manually typing foo.var.items?
I read documentation of jora https://github.com/discoveryjs/jora and could not found the solution. I might be missing something. It feels like there's some function or a way to do that but I can't get it.
There is no method for such problem, but you can use a query like this:
foo..values().['items' in keys()]
This will return an array of all objects with items
field. You may use it as a helper:
$find: => ..values().[$$ in keys()];
foo.$find('items')
@lahmatiy, Thank you! Also it's a really nice idea to create helpers for specific needs in my project.