[英]How to deal with jsonb objects in postgres databases in cube.js?
I have postgres database with a jsonb column which contains custom attribute keys and values.我有一个包含自定义属性键和值的 jsonb 列的 postgres 数据库。 Is there any approach to get these to show up in the dimensions?
有没有办法让这些显示在维度中?
You can use ->>
json operator for that https://www.postgresql.org/docs/9.5/functions-json.html .您可以为该https://www.postgresql.org/docs/9.5/functions-json.html使用
->>
json 运算符。 For example:例如:
cube(`Users`, {
sql: `select * from users`,
// ...
dimensions: {
firstName: {
sql: `${CUBE}.attributes->>'firstName'`,
type: `string`
},
lastName: {
sql: `${CUBE}.attributes->>'lastName'`,
type: `string`
}
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.