Created
March 3, 2014 16:30
-
-
Save poga/9328711 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function mount-storage (plx, schema, table, cb) | |
# import a package | |
next <- plx.import-bundle-funcs 'jsonpatch', require.resolve("jsonpatch/package.json") | |
<- next! | |
<- plx.mk-user-func 'plv8x.json apply_patch(json, json[])', 'jsonpatch:apply_patch' | |
# import a module (without package.json) | |
next <- plx.import-bundle-funcs 'pgrest_schemaless', require.resolve('./user_func') | |
<- next! | |
# ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
storage <- mount-storage plx, SCHEMA, TABLE | |
err, {row}? <- plx.conn.query "select pgrest_schemaless_set($1) as ret" [{}] | |
throw err if err | |
# Uncaught Error: TypeError: Cannot read property 'pgrest_schemaless_set' of undefined | |
# at Connection.<anonymous> (/Users/poga/MyProject/pgrest/pgrest-schemaless/node_modules/pgrest/node_modules/plv8x/node_modules/pg/lib/native/index.js:202:17) | |
# at Connection.EventEmitter.emit (events.js:95:17) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function pgrest_schemaless_set (params) | |
query = "select apply_patch('{}'::json, ARRAY['{\"op\": \"add\", \"path\": \"/new\", \"value\": \"new\"}'::json]) as ret;" | |
console.log query | |
return plv8.execute query | |
pgrest_schemaless_set.$plv8x = '(plv8x.json):plv8x.json' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment