discoveryjs / discovery

A framework for rapid data (JSON) analysis, shareable serverless reports and dashboards
https://discoveryjs.github.io/discovery/
MIT License
331 stars 6 forks source link

How to search across all data paths? #92

Open FeltBoots opened 2 years ago

FeltBoots commented 2 years ago

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.

lahmatiy commented 2 years ago

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')
FeltBoots commented 2 years ago

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