Skip to content
Open
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
15 changes: 12 additions & 3 deletions lib/persistence.store.sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,19 +579,21 @@ function config(persistence, dialect) {
* @param callback function to be called taking an array with
* result objects as argument
*/
persistence.DbQueryCollection.prototype.list = function (tx, callback) {
persistence.DbQueryCollection.prototype.list = function (tx, callback, errorCallback) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflicting, for instance, with the convention of persistence.flush (callback should check second arg for error)

var args = argspec.getArgs(arguments, [
{ name: 'tx', optional: true, check: persistence.isTransaction, defaultValue: null },
{ name: 'callback', optional: false, check: argspec.isCallback() }
{ name: 'callback', optional: false, check: argspec.isCallback() },
{ name: 'errorCallback', optional: true, check: argspec.isCallback(), defaultValue: null }
]);
tx = args.tx;
callback = args.callback;
errorCallback = args.errorCallback;

var that = this;
var session = this._session;
if(!tx) { // no transaction supplied
session.transaction(function(tx) {
that.list(tx, callback);
that.list(tx, callback, errorCallback);
});
return;
}
Expand Down Expand Up @@ -708,6 +710,13 @@ function config(persistence, dialect) {
}
callback(results);
that.triggerEvent('list', that, results);
}, function (tx, error) {
if (persistence.debug) {
console.log(tx, error);
}
if (typeof errorCallback == 'function') {
errorCallback(tx, error);
}
});
});
};
Expand Down