如何使用 mongodb 和 cubejs 格式化时间类型的数据?

问题描述

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

我没有找到时间类型的格式。 所以我尝试使用 sqlPARSE_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

解决方法

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

谢谢