0.1.1 • Published 6 years ago
rethink-hapi v0.1.1
#RETHINK-HAPI
An HapiJS plugin for rethinkdb.
This plugin is only compatible with hapijs v17.x.x and uses the rethinkdb official driver.
Installation
yarn add rethink-hapi
If you prefer npm:
npm -i rethink-hapi
Usage
Register the plugin to the server
Obtain a rethinkdb connection
WARNING: Never forget to close the connection via await conn.close().
const Hapi = require('hapi')
const server = Hapi.Server()
// Register the plugin
server.register(require('rethink-hapi'))
// Obtain a connection
async function testRethinkConnection () {
const {connect, r} = server.plugins['rethink-hapi']
const conn = await connect()
const db = await r.dbList().run(conn)
console.log(db)
await conn.close()
}
testRethinkConnection()
// TODO: Create demo
Plugin options
host
: rethinkdb hostname. Defaultlocalhost
port
: rethinkdb port. Default28015
db
: database name. Defaulttest
username
: database username. Defaultadmin
password
: database user password. Default''
ssl
: a hash of options to support SSL connections. Defaultnull
Function and object exposed by rethink-hapi
connect
: A function used to get a connection.r
: The top-level ReQL namespace.