-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hey there @burggraf, nice job!
I'm wondering if there's any progress getting this added as an official extension or maybe on dbdev as a pglet?
I was wanting to use JSONata within postgres functions directly...thanks to this I can!
create or replace function evaluate_jsonata(
in jsonata_expression text,
in json_data jsonb,
out result jsonb,
out error text
)
returns SETOF record as $$
try {
const jsonata = require('https://cdn.jsdelivr.net/npm/jsonata@1.8.6/jsonata.min.js');
const expression = jsonata(jsonata_expression);
const result = expression.evaluate(json_data);
return {
result: result,
error: null
};
} catch (e) {
return {
result: null,
error: e.message
};
}
$$ language plv8;
select result from test_jsonata('$sum(*)','{"a":1,"b":2}')
returns 3 🤘🏻
So cool!!
Joonel
Metadata
Metadata
Assignees
Labels
No labels