hapi-nedb-connector
Advanced tools
Comparing version 0.0.4 to 0.1.0
@@ -18,21 +18,19 @@ 'use strict'; | ||
var db, collections = {}; | ||
var collections = {}; | ||
db = { | ||
collection: function (collection) { | ||
if (!collections[collection]) { | ||
if (options.directory) { | ||
options.filename = options.directory + collection + '.nedb'; | ||
options.autoload = true; | ||
} | ||
var db = function (collection) { | ||
if (!collections[collection]) { | ||
if (options.directory) { | ||
options.filename = options.directory + collection + '.nedb'; | ||
options.autoload = true; | ||
} | ||
collections[collection] = new Datastore(options); | ||
collections[collection] = new Datastore(options); | ||
if (options.directory && options.autoCompactionInterval) { | ||
collections[collection].persistence.setAutocompactionInterval(options.autoCompactionInterval) | ||
} | ||
if (options.directory && options.autoCompactionInterval) { | ||
collections[collection].persistence.setAutocompactionInterval(options.autoCompactionInterval) | ||
} | ||
return collections[collection]; | ||
} | ||
}; | ||
return collections[collection]; | ||
} | ||
@@ -39,0 +37,0 @@ var compact = function (collection) { |
{ | ||
"name": "hapi-nedb-connector", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"description": "A simple connector for hapi and nedb", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1,3 +0,8 @@ | ||
# hapi-nedb-connector [](https://www.npmjs.com/package/node-schedule) [](https://travis-ci.org/jonhester/hapi-nedb-connector) | ||
# hapi-nedb-connector [](https://www.npmjs.com/package/hapi-nedb-connector) [](https://travis-ci.org/jonhester/hapi-nedb-connector) | ||
A simple connector for hapi and nedb | ||
## Installation | ||
``` | ||
npm install hapi-nedb-connector | ||
``` |
@@ -67,3 +67,3 @@ 'use strict'; | ||
var plugin = request.server.plugins['hapi-nedb-connector']; | ||
plugin.db.collection('test').insert({id: 1, test: [1,2,3]}); | ||
plugin.db('test').insert({id: 1, test: [1,2,3]}); | ||
@@ -116,7 +116,7 @@ done(); | ||
var plugin = request.server.plugins['hapi-nedb-connector']; | ||
plugin.db.collection('test').insert({id: 1, test: [1,2,3]}); | ||
plugin.db('test').insert({id: 1, test: [1,2,3]}); | ||
expect(plugin.db).to.exist(); | ||
plugin.db.collection('test').find({ id: 1 }, function (err, docs) { | ||
plugin.db('test').find({ id: 1 }, function (err, docs) { | ||
@@ -123,0 +123,0 @@ expect(docs[0]).to.exist(); |
9
7958
164