1.0.3 • Published 7 years ago

pg-plv8 v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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