Commit ff18d8dc authored by Milan Wikarski's avatar Milan Wikarski

Added onsuccess() to query

parent 7f223505
......@@ -17,6 +17,8 @@ class Query {
this.success = null;
this.rows = null;
this.err = null;
this._onsuccess = null;
}
/**
......@@ -39,6 +41,17 @@ class Query {
return is.not.emptyString(this.query);
}
/**
* Sets the onsuccess callback
*
* @param {Function} onsuccess
* @returns Query
*/
onsuccess(onsuccess) {
this._onsuccess = onsuccess;
return this;
}
/**
* Executes a generic query
* - returns `true` if successful; `false` otherwise
......@@ -59,6 +72,11 @@ class Query {
resolve(false);
} else {
this.rows = res.rows;
if (this._onsuccess instanceof Function) {
this._onsuccess();
}
resolve(true);
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment