mina-mysql-manager
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -22,3 +22,2 @@ (function() { | ||
this.drain = bind(this.drain, this); | ||
this.query = bind(this.query, this); | ||
this.error = bind(this.error, this); | ||
@@ -31,4 +30,26 @@ this.end = bind(this.end, this); | ||
this.drainDefense = false; | ||
this._promise = null; | ||
} | ||
InstantConnect.prototype.promise = function() { | ||
if (this._promise != null) { | ||
return this._promise; | ||
} else { | ||
return this._promise = new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
_this.once('endQ', resolve); | ||
return _this.once('errorQ', reject); | ||
}; | ||
})(this)); | ||
} | ||
}; | ||
InstantConnect.prototype.then = function(onSuccess, onFailure) { | ||
return this.promise().then(onSuccess, onFailure); | ||
}; | ||
InstantConnect.prototype["catch"] = function(callback) { | ||
return this.promise().then(callback); | ||
}; | ||
InstantConnect.prototype.end = function() { | ||
@@ -55,3 +76,4 @@ return this.drain(); | ||
InstantConnect.prototype.query = function(queryString, successFn, failFn) { | ||
return this.client.query(queryString, (function(_this) { | ||
this.promise(); | ||
this.client.query(queryString, (function(_this) { | ||
return function(err, rows) { | ||
@@ -62,3 +84,5 @@ if (err != null) { | ||
} else { | ||
successFn(err); | ||
if (successFn != null) { | ||
successFn(err); | ||
} | ||
} | ||
@@ -72,8 +96,9 @@ } else if (rows != null) { | ||
if (err != null) { | ||
return err; | ||
return _this.emit('errorQ', err); | ||
} else { | ||
return rows; | ||
return _this.emit('endQ', rows); | ||
} | ||
}; | ||
})(this)); | ||
return this; | ||
}; | ||
@@ -80,0 +105,0 @@ |
{ | ||
"name": "mina-mysql-manager", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Very Simply Managing mysql and mariadb with pool and query of xml like ibatis or mybatis", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
13426
325