zoukankan      html  css  js  c++  java
  • cube.js 通过require 加载schema

    我们可以通过require 的模式加载配置好的schema,但是需要注意sql 以及drillMembers 必须是一个函数()=> string 或者()=>string[]

    几点说明

    • 自己开发的schema 不能再schema文件夹中
    • sql 以及drillMembers 必须是一个函数()=> string 或者()=>string[]

    参考使用

    • 自定义schema


    内容

     
    module.exports = {
      sql: ()=> `SELECT * FROM sf100000.call_center`,
      joins: {
     
      },
     
      measures: {
        count: {
          type: `count`
        }
      },
     
      dimensions: {
        ccCallCenterId: {
          sql: ()=>`cc_call_center_id`,
          type: `string`
        },
     
        ccName: {
          sql: ()=>`cc_name`,
          type: `string`
        },
     
        ccClass: {
          sql: ()=>`cc_class`,
          type: `string`
        },
     
        ccHours: {
          sql: ()=>`cc_hours`,
          type: `string`
        },
     
        ccManager: {
          sql: ()=>`cc_manager`,
          type: `string`
        },
     
        ccMktClass: {
          sql: ()=>`cc_mkt_class`,
          type: `string`
        },
     
        ccMktDesc: {
          sql: ()=>`cc_mkt_desc`,
          type: `string`
        },
     
        ccMarketManager: {
          sql: ()=>`cc_market_manager`,
          type: `string`
        },
     
        ccDivisionName: {
          sql: ()=>`cc_division_name`,
          type: `string`
        },
     
        ccCompanyName: {
          sql: ()=>`cc_company_name`,
          type: `string`
        },
     
        ccStreetNumber: {
          sql: ()=>`cc_street_number`,
          type: `string`
        },
     
        ccStreetName: {
          sql: ()=>`cc_street_name`,
          type: `string`
        },
     
        ccStreetType: {
          sql: ()=>`cc_street_type`,
          type: `string`
        },
     
        ccSuiteNumber: {
          sql: ()=>`cc_suite_number`,
          type: `string`
        },
     
        ccCity: {
          sql: ()=>`cc_city`,
          type: `string`
        },
     
        ccCounty: {
          sql: ()=>`cc_county`,
          type: `string`
        },
     
        ccState: {
          sql: ()=>`cc_state`,
          type: `string`
        },
     
        ccZip: {
          sql: ()=>`cc_zip`,
          type: `string`
        },
     
        ccCountry: {
          sql: ()=>`cc_country`,
          type: `string`
        },
     
        ccRecStartDate: {
          sql: ()=>`cc_rec_start_date`,
          type: `time`
        },
     
        ccRecEndDate: {
          sql: ()=>`cc_rec_end_date`,
          type: `time`
        }
      },
     
      dataSource: `default`
    };
    • 引用schema
    const schme_info = require("../myapp/CallCenter")
    cube(`CallCenter`, schme_info);

    效果

    说明

    以上问题在cube.js 的slack 中也有人问到

    参考资料

    https://cube.dev/docs/schema/dynamic-schema-creation

  • 相关阅读:
    稀疏自编码器一览表
    ZOJ 3886 Nico Number(筛素数+Love(线)Live(段)树)
    K好数(DP)
    【BZOJ4025】二分图
    又一次认识java(七) ---- final keyword
    二分查找
    从朴素贝叶斯分类器到贝叶斯网络(下)
    最近感到深深的绝望,感觉自己太菜了
    leetcode No.19 删除链表的倒数第N个节点 (python3实现)
    leetcode No.94 二叉树的中序遍历 (python3实现)
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/14655929.html
Copyright © 2011-2022 走看看