diff --git a/src/database/level.js b/src/database/level.js index 5d415bcd1d..a3cec2ef49 100644 --- a/src/database/level.js +++ b/src/database/level.js @@ -13,7 +13,6 @@ var winston = require('winston'), nconf = require('nconf'), path = require('path'), - async = require('async'), express = require('express'), utils = require('./../../public/src/utils.js'), levelup, @@ -81,22 +80,6 @@ db.close(callback); }; - var helpers = {}; - - helpers.iterator = function(fn, keys, value, callback) { - var results = []; - - async.each(keys, function(key, next) { - module[fn](key, value, function(err, result) { - results.push(result); - next(); - }); - }, function(err) { - callback(err, results); - }); - }; - module.helpers = module.helpers || {}; - module.helpers.level = helpers; - + module.helpers.level = require('./level/helpers'); }(exports)); \ No newline at end of file diff --git a/src/database/level/helpers.js b/src/database/level/helpers.js new file mode 100644 index 0000000000..bc7b352203 --- /dev/null +++ b/src/database/level/helpers.js @@ -0,0 +1,19 @@ +"use strict"; + +var helpers = {}, + async = require('async'); + +helpers.iterator = function(fn, keys, value, callback) { + var results = []; + + async.each(keys, function(key, next) { + module[fn](key, value, function(err, result) { + results.push(result); + next(); + }); + }, function(err) { + callback(err, results); + }); +}; + +module.exports = helpers; \ No newline at end of file diff --git a/src/database/mongo.js b/src/database/mongo.js index ccc593dcc0..290aa5f9c9 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -109,56 +109,7 @@ db.close(); }; - - var helpers = {}; - helpers.findItem = function(data, key) { - if(!data) { - return null; - } - - for(var i=0; i