0.1.1 • Published 7 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-hapiIf you prefer npm:
npm -i rethink-hapiUsage
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. Defaultlocalhostport: rethinkdb port. Default28015db: database name. Defaulttestusername: database username. Defaultadminpassword: 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.