cube-js/cube

Set SQL value in Meta field of a Dimension

開放

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

 (2 則留言) (2 個反應) (0 位負責人)Rust (1,965 個分叉)batch import
help wanted

倉庫指標

星標
 (19,563 顆星)
PR 合併指標
 (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.

貢獻者指南