Can plv8 JavaScript language extension call 3rd party libraries?

Viewed 1589

In Postgresql, I want to call 3rd party libraries like moment.js or AWS lambda JS Client to invoke serverless functions from within the DB. I don't see any docs or examples how to do so: https://github.com/plv8/plv8/blob/master/README.md

Is this possible and where can I find examples of how to 'import' or 'require' additional libraries?

3 Answers

Quite a while later... it is possible in AWS RDS PostgreSQL to invoke Lambda functions in versions:

  • 14.1 and higher minor versions
  • 13.2 and higher minor versions
  • 12.6 and higher minor versions

with select statements like:

Synchronous

SELECT * FROM aws_lambda.invoke(:'aws_lambda_arn_1', '{"body": "Hello from Postgres!"}'::json);

Async

SELECT * FROM aws_lambda.invoke(:'aws_lambda_arn_1', '{"body": "Hello from Postgres!"}'::json, 'Event');

Of course, there is more to setting it up in the instructions here: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL-Lambda.html

Related