cube-js/cube

Set SQL value in Meta field of a Dimension

Open

#3.143 geöffnet am 21. Juli 2021

Auf GitHub ansehen
 (2 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)Rust (1.965 Forks)batch import
help wanted

Repository-Metriken

Stars
 (19.563 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 5T 16h) (138 gemergte PRs in 30 T)

Beschreibung

Is your feature request related to a problem? Please describe. I'd like to be able to display a link on the frontend of my application with the text being the name of the data I'm linking. For example I want to link to a resource like <a href={link}>{nameOfResource}</a>. This would be much easier if I could fetch both the name and the link at the same time as a singular dimension, rather than having to combine them on the front end.

Describe the solution you'd like I'd like something like this:

link: {
      sql: `CONCAT('http://www.example.com/',${CUBE.id},'/')`,
      type: `string`,
      format: `link`,
      meta: {
        name: {
             sql: `${CUBE.name}`
            }
      }
}

Or something similar. Basically here I want to fetch both the name and the link for the name at the same time. Describe alternatives you've considered Currently as a work around, I have to query for both CUBE.name and CUBE.link and then write some glue code on the front end to turn them into 1 dimension to render. This is okay, but definitely not ideal. Currently, with the existing link API you can only set static text for the dimension like in this example:

    crmLink: {
      sql: `'https://na1.salesforce.com/' || id`,
      type: `string`,
      format: {
        label: `View in Salesforce`,
        type: `link`,
      },
    },

But imagine you had tens or hundreds of links for various CRM entries, you wouldn't want to display View in Salesforce for ALL of them. You'd want an easier way to distinguish which one you're going to click.

Contributor Guide