rethinkdb-primus
Use rethinkdb over a primus connection
Installation
npm i --save rethinkdb-primus
Usage
Server Example
On the server just import and setup the rethinkdb-primus
primus plugin
// ... setup servervar primus = server transport: 'engine.io' // technically, any transport should work parser: 'binary' primus // rethinkdb connection options host: 'localhost' port: 28015 primus
Client Example
var net = var rethinkdb = var client = // The client monkey patches rethinkdb (and, temporarily, net and process)var opts = net: net process: process rethinkdb: rethinkdbclient
Validation Example
rethinkdb-primus uses validate-reql, which monkey patches rethinkdb w/ some new query methods for validation
r.rvRef
, rvValidate
, and r.rvOpt
Example: Custom validation using refs: Place r.rvRef('<name>')
in place of ReQL you want to manually validate in your whitelist ReQL
Note: if the actual value from the ReQL is a sequence of ReQL you will have to test it as Rethink AST
/* server.js */var queryWhitelist = r // specify databaseprimus/* client.js */var rethinkdb = var client = // The client monkey patches rethinkdb (and, temporarily, net and process)var opts = net: process: process rethinkdb: rethinkdbclient
Credits
Thank you Mike Mintz! Code is heavily inspired by rethinkdb-websocket-server
License
MIT