Skip to content

Commit

Permalink
Updated the readme a bit and exported the db from the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
peeter-tomberg committed Aug 10, 2014
1 parent 593f978 commit 5cac03a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[ ![Codeship Status for peeter-tomberg/hapi-mongodb-promises](https://codeship.io/projects/6d63ee10-02c1-0132-49a3-5eecd43daaed/status?branch=master)](https://codeship.io/projects/30317)
[![Coverage Status](https://coveralls.io/repos/peeter-tomberg/hapi-mongodb-promises/badge.png)](https://coveralls.io/r/peeter-tomberg/hapi-mongodb-promises)
[![Coverage Status](https://coveralls.io/repos/peeter-tomberg/hapi-mongodb-promises/badge.png)](https://coveralls.io/r/peeter-tomberg/hapi-mongodb-promises)
[![Code Climate](https://codeclimate.com/github/peeter-tomberg/hapi-mongodb-promises/badges/gpa.svg)](https://codeclimate.com/github/peeter-tomberg/hapi-mongodb-promises)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"description": "",
"main": "index.js",
"author": "Peeter Tomberg peeter.tomberg@gmail.comg",
"author": "Peeter Tomberg peeter.tomberg@gmail.com",
"license": "ISC",
"dependencies": {
"joi": "^4.6.2",
Expand All @@ -20,7 +20,7 @@
"hapi": ">= 6.x"
},
"scripts": {
"test": "mocha ",
"test": "mocha",
"testw": "mocha --watch",
"coverage": "mocha --reporter html-cov > coverage.html",
"coveralls": "mocha --reporter mocha-lcov-reporter | coveralls"
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports.register = function (plugin, options, next) {
}

MongoClient.connect(options.url, options.options || {}, function (error, db) {

if (error) {
next(error);
return;
Expand All @@ -27,6 +28,7 @@ exports.register = function (plugin, options, next) {
plugin.expose('insert', mongoWrapper.insert.bind(mongoWrapper));
plugin.expose('insertOne', mongoWrapper.insertOne.bind(mongoWrapper));
plugin.expose('update', mongoWrapper.update.bind(mongoWrapper));
plugin.expose('db', db);

next();
});
Expand Down
6 changes: 4 additions & 2 deletions test/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('Mongo plugin', function() {
});
});

it('should register with just an url url', function(done) {
it('should register with just an url', function(done) {
server.pack.register({
plugin: plugin,
options : {
Expand All @@ -66,7 +66,7 @@ describe('Mongo plugin', function() {
});
});

it ('should expose functions', function (done) {
it ('should expose functions and the db object', function (done) {

server.pack.register({
plugin: plugin,
Expand All @@ -80,6 +80,8 @@ describe('Mongo plugin', function() {
expect(server.plugins['hapi-mongodb-promises'][name]).to.be.a(Function);
});

expect(server.plugins['hapi-mongodb-promises'].db).to.exist();

done();
});

Expand Down

0 comments on commit 5cac03a

Please sign in to comment.