Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/diskdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
var path = require('path'),
c = require('chalk'),
e = c.red,
s = c.green;
debug = require('debug')('diskdb');

//local modules
var util = require('./util');
Expand All @@ -23,20 +23,18 @@ var db = {
var _db = {};
_db.path = path;
this._db = _db;
console.log(s('Successfully connected to : ' + path));
debug('Successfully connected to : ' + path);
if (collections) {
this.loadCollections(collections);
}
} else {
console.log(e('The DB Path [' + path + '] does not seem to be valid. Recheck the path and try again'));
return false;
throw(e('The DB Path [' + path + '] does not seem to be valid. Recheck the path and try again'));
}
return this;
},
loadCollections: function(collections) {
if (!this._db) {
console.log(e('Initialize the DB before you add collections. Use : ', 'db.connect(\'path-to-db\');'));
return false;
throw(e('Initialize the DB before you add collections. Use : ', 'db.connect(\'path-to-db\');'));
}
if (typeof collections === 'object' && collections.length) {
for (var i = 0; i < collections.length; i++) {
Expand All @@ -48,7 +46,7 @@ var db = {
this[_c] = new require('./collection')(this, _c);
}
} else {
console.log(e('Invalid Collections Array.', 'Expected Format : ', '[\'collection1\',\'collection2\',\'collection3\']'));
throw(e('Invalid Collections Array.', 'Expected Format : ', '[\'collection1\',\'collection2\',\'collection3\']'));
}
return this;
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
},
"dependencies": {
"chalk": "^0.4.0",
"node-uuid": "^1.4.1",
"merge": "^1.1.3"
"debug": "^3.1.0",
"merge": "^1.1.3",
"node-uuid": "^1.4.1"
},
"scripts": {
"test": "grunt"
Expand Down