node-plv8
require()
node modules in PLV8. Optimize your Node.js Backend by offloading work directly onto the database (PostgreSQL). Send/receive events between Node and PLV8.
Install
$ npm install --save plv8
Usage
Node API
install (module, [cwd])
Install a Node module which can be loaded into the plv8 context by using the require()
method.
uninstall (module)
Remove a previously installed module.
eval (code)
Evaluate a block of Javascript on the fly.
on (event, handler)
Listen for a Postgres NOTIFY event, and invoke the given handler
when the event is emitted.
Postres API
require (module)
Load an installed Node module.
log (level, message)
Send a log message to the Node.js application.
emit (event, payload)
Emit an aribtrary event to the Node.js application via NOTIFY.
Example
// setup plv8 connectionconst PLV8 = const plv8 = client: 'pg' connection: // knex.js connection object // setup a log listenerplv8 // setup a listenerplv8 // install the lodash module so that it can be loaded (via require()) laterplv8
// send some events to the client plv8
2.
PLV8 Extension
This module requires the plv8 Postgres extension.
$ easy_install pgxnclient$ pgxnclient install plv8
Forked!
This is a fork of plv8x that has been streamlined down to the essentials, and extended with additional API features. Important differences:
- 90%+ smaller than plv8x (~20kb vs. 300+ kb)
- Removed node-pg-native
- Removed Livescript / Coffeescript Support
- Removed CLI
- Removed unused/unneeded dependencies
- Transpile modules using babel instead of browserify
License
MIT