【发布时间】:2015-12-10 08:15:31
【问题描述】:
- 配置的 Datasource.groovy 和 BuildConfig.groovy
- 在 groovy 服务中查询 Postgres 数据库时需要帮助。
在 postgres 中有一个下表: table structure
需要在 grails 应用程序中编写以下 SQL 查询:
SELECT json_agg(r)
FROM(
SELECT data#>'{"name"}' as program,data#>'{"country"}' as agency,sum(cast(cast(data#>'{"amount"}' as text)as Integer)) as total_amount
FROM salary
group by data#>'{"name"}',data#>'{"country"}'
order by program, agency
)r
【问题讨论】:
-
需要根据过滤条件从postgres中查询JSONB数据,或者说需要从mongodb迁移到postgres,使用mongo colllection对应的如下schema: id, data (jsonb datatype) .不确定我是否清楚地解释了我的观点..
标签: postgresql grails grails-orm