Skip to content

Commit

Permalink
Clearing the DataStore before loading it's data from persistent storage
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jul 4, 2015
1 parent c368df7 commit d11c60a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/haro.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class Haro {
cmd (type, ...args) {
let defer = deferred();

if (!this.adapters[type]) {
if (!this.adapters[type] || !adapter[type]) {
defer.reject(new Error(type + " not configured for persistent storage"));
} else {
adapter[type].apply(this, [this].concat(args)).then(function (arg) {
Expand Down Expand Up @@ -448,6 +448,7 @@ class Haro {
}

load (type = "mongo") {
this.clear();
return this.cmd(type, "get");
}

Expand Down
3 changes: 2 additions & 1 deletion lib/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
value: function cmd(type) {
var defer = deferred();

if (!this.adapters[type]) {
if (!this.adapters[type] || !adapter[type]) {
defer.reject(new Error(type + " not configured for persistent storage"));
} else {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
Expand Down Expand Up @@ -499,6 +499,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
value: function load() {
var type = arguments[0] === undefined ? "mongo" : arguments[0];

this.clear();
return this.cmd(type, "get");
}
}, {
Expand Down
Loading

0 comments on commit d11c60a

Please sign in to comment.