【问题标题】:How to format time-type data with mongodb and cubejs?如何使用 mongodb 和 cubejs 格式化时间类型的数据?
【发布时间】:2021-04-17 03:49:24
【问题描述】:

我找到了这个主题的网址:

我没有找到时间类型的格式。 所以我尝试使用sql:PARSE_TIMESTAMP('%Y-%m-%d', date)

    createdat: {
      sql: `PARSE_TIMESTAMP('%Y-%m-%d',${CUBE}.\`createdAt\`)`,
      type: `time`
    },

它会返回一个错误:

Error: Error: scalar function 'parse_timestamp' is not supported

【问题讨论】:

    标签: sql cube.js


    【解决方案1】:
    createdat: {
        sql: `DATE(${CUBE}.\`createdAt\`, '%Y-%m-%d')`,
        type: `time`
    },
    

    谢谢

    【讨论】:

    • 在 sql 属性中,我们使用特定于我们连接 cube.js 的数据库的函数。他们正在使用 BigQuery 的文档中的示例。
    猜你喜欢
    • 1970-01-01
    • 2019-06-30
    • 2020-10-12
    • 1970-01-01
    • 2011-12-03
    • 1970-01-01
    • 2018-08-30
    • 2015-11-07
    • 2015-02-05
    相关资源
    最近更新 更多