discoveryjs / discovery

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

Feature Request: Ability to provide variable ahead of time #8

Closed obenjiro closed 5 years ago

obenjiro commented 5 years ago

Something that looks like this:

prepare.js

discovery.addVariables({
     '$a': '<($.a.b)>'
})

discovery ui

[{ a: { b: 1 } }].map($a)   // will return [1]

This will help to create Domain Specific Queries and it will save a lot of time for monotonous jobs.

lahmatiy commented 5 years ago

Maybe discovery.addQueryHelpers() is what you are requesting for?

discovery.addQueryHelpers({
   foo: current => discovery.query('$.a.b', current)
});

Usage:

[{ a: { b: 1 } }].foo()
obenjiro commented 5 years ago

That's solves issue for now, but there is no autocomplete for functions :/

lahmatiy commented 5 years ago

Ok, closing the issue then.

there is no autocomplete for functions

That's will be added in future releases. Can you fill a separate issue for this feature?