discovery icon indicating copy to clipboard operation
discovery copied to clipboard

How to search across all data paths?

Open FeltBoots opened this issue 2 years ago • 2 comments

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.

FeltBoots avatar Mar 24 '22 13:03 FeltBoots

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 avatar Mar 24 '22 15:03 lahmatiy

@lahmatiy, Thank you! Also it's a really nice idea to create helpers for specific needs in my project.

FeltBoots avatar Mar 25 '22 02:03 FeltBoots