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

Pass data and context to queryHelpers #74

Closed smelukov closed 2 months ago

smelukov commented 3 years ago
addQueryHelpers({
  foo() {
    console.log(this.data);
    console.log(this.context);
  }
})
lahmatiy commented 2 months ago

Starting Discovery.js 1.0.0-beta.80 (jora 1.0.0-beta.10) custom methods are support for accessing to context via this.context. Custom methods can be a string (jora query) as well, and access to context via # as a regular queries.

Accessing to root data in methods via this.data is not supported. This limitation is due a custom method can be a string (jora query) and @ (or this.data) refers to query root or the method itself instead of root query.