pg-plv8

1.0.3 • Public • Published

node-pg-plv8

NPM version

Use node modules in PLV8. Optimize your Node.js Backend by offloading work directly onto the database (PostgreSQL).

This is a fork of node-plv8 that has been streamlined down to the essentials. The difference:

  • Removed knex in favor of node-postgres

Install

$ npm install --save pg-plv8

Usage

API

install (module, [cwd])

uninstall (module)

eval (code)

Example

const pg = require("pg");
const Pool = pg.Pool;
const PLV8 = require("plv8");
const plv8 = new PLV8(new Pool({ /* postgres pool config */});
 
plv8.install(require.resolve("lodash"))
    .then(() => {
        return plv8.eval(() => {
            const _ = require("lodash");
            return _.map([ 1, 2, 3 ], e => {
                return e + 1;
            });
        })
    })
    .then(result => {
        // result = [ 2, 3, 4 ]
    })
    .catch(err => {
        // handle error
    });

License

MIT

Maintained By

breadboard

Package Sidebar

Install

npm i pg-plv8

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • davidmurdoch