Hacker News new | ask | show | jobs
by vog 4883 days ago
> JSON type and functional indexes

Those "Indexes on Expressions" are really a great feature that can also be combined with XML (not just JSON) and any other types. I recommend everyone to have a look at those:

http://www.postgresql.org/docs/9.2/static/indexes-expression...

1 comments

Is there any way in those expressions to parse JSON and perform arbitrary calculations - i.e. like CouchDB views?
Sure, you can write server side procedures in f.ex. javascript that do arbitrary things with the json.
To be fair, one should note that "only" the languages C, Python, Perl and Tcl [1] are officially supported by PostgreSQL. Also, there are 3rd-party bindings for other languages such as Java, PHP, R, Ruby, Scheme, sh:

http://www.postgresql.org/docs/9.2/interactive/external-pl.h...

However, the PostgreSQL documentation doesn't mention JavaScript support anywhere. Are you sure there exists mature PL/JavaScript binding for PostgreSQL? If so, their docs should be updated.

[1] There's also "pgSQL", but that's a special-purpose language you won't find outside the database world. I don't recommend learning it unless you have strange requirements that make PL/pgSQL a perfect fit. For normale usage, use PL/Python or PL/Perl. In simple cases, use SQL directly.

Yes, #1 hit when you Google for postgresql JavaScript: https://code.google.com/p/plv8js/

I can't vouch for any particular maturity level but seems to have active users and it's been around a few years already.