Hello!
On Wed, Sep 11, 2013 at 1:24 AM, Mathieu Malaterre wrote:
> I was wondering if you could comment on my stackoverflow question:
>
> http://stackoverflow.com/questions/18724482/postgres-columns-attribute-for-json
>
> This is clearly related to the design/implementation of
> ngx_postgres. I need to be able to return as GET operation something
> like this. See how "PersonName" is nested within a "PatientName":
>
[...]
>
> As you notice there is a two level nesting. I was wondering if you
> knew of a way to express that in ngx_postgres + json, or by design
> ngx_postgres always return flat array. I tried using composite type
> for "PersonName" and foreign keys with no luck so far.
>
You can just use the combination ngx_postgres + ngx_lua + lua-cjson +
lua-rds-parser to construct arbitrary JSON structures in your own Lua
code running inside Nginx:
http://wiki.nginx.org/HttpLuaModule
https://github.com/agentzh/lua-rds-parser
http://www.kyne.com.au/~mark/software/lua-cjson.php
BTW, you should not enable the ngx_rds_json module in this combination
because now you directly parse the binary RDS output from ngx_postgres
and generate your own JSON via lua-cjson.
It's worth mentioning that all these components are enabled by default
in the openresty bundle:
http://openresty.org/
This approach also applies to the ngx_drizzle module for MySQL and
Drizzle servers.
I'm cc'ing the openresty-en mailing list:
https://groups.google.com/group/openresty-en And you're encouraged to
join the list and post such questions there in the future :) Thanks!
Best regards,
-agentzh