New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi-rethinkdb

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-rethinkdb

Hapi's rethinkdb plugin

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

hapi-rethinkdb

Hapi (>=8.0) plugin for rethinkdb native driver.

Install hapi-rethinkdb

npm install --save rethinkdb hapi-rethinkdb

Register plugin

You can pass as options either an URL (all are optionals, defaults to: no password, localhost and ) or host and port. Obviously passing an URL is way more convenient (specially for 12factor-compliant apps).

var Hapi = require('hapi');
var server = new Hapi.Server();

server.register({
  register: require('hapi-rethinkdb'),
  opts: { url: 'rethinkdb://:password@domain.tld:port/dbname' }
}, function (err) {
  if (err) console.error(err);
});

Use plugin

The connection object returned by rethinkdb.connect callback is exposed on server.plugins['hapi-rethinkdb'].connection and binded to the context on routes and extensions as this.rethinkdbConn. You can find the rethinkdb library itself exposed on server.plugins['hapi-rethinkdb'].library and server.plugins['hapi-rethinkdb'].rethinkdb or binded to the context on routes and extensions as this.rethinkdb.

From a handler you can use it like:

function handler (request, response) {
  var r = request.server.plugins['hapi-rethinkdb'].rethinkdb;
  // r === this.rethinkdb;

  var conn = request.server.plugins['hapi-rethinkdb'].connection;
  // conn === this.rethinkdbConn;

  r.table('example').run(conn, function (err, cursor) {
    cursor.each(console.log);
  });
}

License

Licensed under the terms of the ISC. A copy of the license can be found in the file LICENSE.

© 2015, Jose-Luis Rivas <me@ghostbar.co>

Keywords

FAQs

Package last updated on 21 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc