cube-js/cube

Set SQL value in Meta field of a Dimension

Open

#3,143 建立於 2021年7月21日

在 GitHub 查看
 (2 留言) (2 反應) (0 負責人)Rust (1,965 fork)batch import
help wanted

倉庫指標

Star
 (19,563 star)
PR 合併指標
 (平均合併 5天 16小時) (30 天內合併 138 個 PR)

描述

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.

貢獻者指南