Skip to content

Instantly share code, notes, and snippets.

View xwmx's full-sized avatar

William Melody xwmx

View GitHub Profile
@xwmx
xwmx / postsql.sql
Created October 18, 2013 21:11 — forked from tobyhede/postsql.sql
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
@xwmx
xwmx / gist:7061260
Last active December 25, 2015 23:59
json pl/v8 functions (not currently tested)
CREATE or REPLACE FUNCTION
json_get(data json, prop text) RETURNS JSON as $$
prop = prop.split('.');
for (var i = 0, len = prop.length; i < len - 1; i++) {
data = data[prop[i]];
}
return data[prop[len - 1]];
$$ LANGUAGE plv8 STABLE STRICT;
### Keybase proof
I hereby claim:
* I am alphabetum on github.
* I am williammelody (https://keybase.io/williammelody) on keybase.
* I have a public key whose fingerprint is E40E 93A0 B64B 2240 1128 7058 B720 9D44 B320 8C42
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am xwmx on github.
  • I am williammelody (https://keybase.io/williammelody) on keybase.
  • I have a public key whose fingerprint is E40E 93A0 B64B 2240 1128 7058 B720 9D44 B320 8C42

To claim this, I am signing this object: