Permalink
Browse files

fix: a bug in yukari delete

  • Loading branch information...
XadillaX committed Oct 12, 2016
1 parent 6923a1a commit 5446a64d14dd3d68ee183be7f8e93cfc46757022
Showing with 3 additions and 6 deletions.
  1. +3 −6 lib/yukari.js
@@ -178,7 +178,7 @@ class Yukari {
if(callback === undefined) callback = _emptyCallback;

if(this.$source === "new") {
return callback(new Error("You must call this function via a new Yukari object."));
return callback(new Error("You can't call this function via a new Yukari object."));
}

let pk;
@@ -198,14 +198,11 @@ class Yukari {
}, {});
}

const self = this;
this.$model.where(pk).limit("0, 1").delete(function(err, result, sql) {
if(err) return callback(err);
if(!result) return callback(new Error("unknown error."));
if(!result.affectedRows) {
return callback(new Error("Out-dated yukari object."));
}

this.$source = "delete";
self.$source = "delete";
return callback(undefined, true, sql);
});
}

0 comments on commit 5446a64

Please sign in to comment.