hapi-rethinkdb
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -28,5 +28,8 @@ 'use strict'; | ||
plugin.expose('client', conn); | ||
plugin.expose('connection', conn); | ||
plugin.expose('library', rethink); | ||
plugin.bind({ rethinkdb: conn }); | ||
plugin.bind({ | ||
rethinkdbConn: conn, | ||
rethinkdb: rethink | ||
}); | ||
@@ -33,0 +36,0 @@ plugin.log(['hapi-rethinkdb', 'info'], 'RethinkDB connection established'); |
{ | ||
"name": "hapi-rethinkdb", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Hapi's rethinkdb plugin", | ||
@@ -26,11 +26,12 @@ "main": "index.js", | ||
"dependencies": { | ||
"rethinkdb": "^1.16.2" | ||
}, | ||
"devDependencies": { | ||
"hapi": "^8.2.0", | ||
"rethinkdb": "^2.0.0", | ||
"mocha": "^2.1.0" | ||
}, | ||
"peerDependencies": { | ||
"hapi": "^8.2.0" | ||
"hapi": "^8.2.0", | ||
"rethinkdb": "^2.0.0" | ||
} | ||
} |
@@ -6,2 +6,7 @@ hapi-rethinkdb | ||
Install hapi-rethinkdb | ||
---------------------- | ||
npm install --save rethinkdb hapi-rethinkdb | ||
Register plugin | ||
@@ -25,4 +30,18 @@ --------------- | ||
The connection object returned by `rethinkdb.connect` callback is exposed on `server.plugins['hapi-rethinkdb'].client` and binded to the context on routes and extensions as `this.rethinkdb`. You can find the `rethinkdb` library itself exposed on `server.plugins['hapi-rethinkdb'].library`. | ||
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` 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 | ||
@@ -33,2 +52,2 @@ ------- | ||
© 2015, jose-Luis Rivas `<me@ghostbar.co>` | ||
© 2015, Jose-Luis Rivas `<me@ghostbar.co>` |
@@ -22,9 +22,9 @@ /* global describe,it,afterEach,beforeEach */ | ||
}, function () { | ||
assert(server.plugins['hapi-rethinkdb'].client, 'No RethinkDB client returned'); | ||
assert(server.plugins['hapi-rethinkdb'].connection, 'No RethinkDB connection returned'); | ||
assert( | ||
server.plugins['hapi-rethinkdb'].client.host === 'localhost', | ||
server.plugins['hapi-rethinkdb'].connection.host === 'localhost', | ||
'Connected to incorrect address' | ||
); | ||
assert( | ||
server.plugins['hapi-rethinkdb'].client.port === 28015, | ||
server.plugins['hapi-rethinkdb'].connection.port === 28015, | ||
'Connected to incorrect port' | ||
@@ -40,3 +40,3 @@ ); | ||
}, function () { | ||
assert(server.plugins['hapi-rethinkdb'].client.open, 'Did not connect'); | ||
assert(server.plugins['hapi-rethinkdb'].connection.open, 'Did not connect'); | ||
done(); | ||
@@ -52,7 +52,7 @@ }); | ||
assert( | ||
server.plugins['hapi-rethinkdb'].client.host === 'localhost', | ||
server.plugins['hapi-rethinkdb'].connection.host === 'localhost', | ||
'Connected to incorrect address' | ||
); | ||
assert( | ||
server.plugins['hapi-rethinkdb'].client.port === 28015, | ||
server.plugins['hapi-rethinkdb'].connection.port === 28015, | ||
'Connected to incorrect port' | ||
@@ -70,7 +70,7 @@ ); | ||
assert( | ||
server.plugins['hapi-rethinkdb'].client.host === 'localhost', | ||
server.plugins['hapi-rethinkdb'].connection.host === 'localhost', | ||
'Connected to incorrect address' | ||
); | ||
assert( | ||
server.plugins['hapi-rethinkdb'].client.port === 28015, | ||
server.plugins['hapi-rethinkdb'].connection.port === 28015, | ||
'Connected to incorrect port' | ||
@@ -77,0 +77,0 @@ ); |
6955
7
104
51
3
+ Addedbluebird@2.11.0(transitive)
+ Addedrethinkdb@2.4.2(transitive)
- Removedrethinkdb@^1.16.2
- Removedbluebird@3.7.2(transitive)
- Removedrethinkdb@1.16.2(transitive)