Skip to content

Commit

Permalink
Include sequentially on transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliano Girardello committed Nov 27, 2020
1 parent 97b5c67 commit 3f62863
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ declare module 'node-firebird' {
export interface Transaction {
query(query: string, params: any[], callback: QueryCallback): void;
execute(query: string, params: any[], callback: QueryCallback): void;
sequentially(query: string, params: any[], rowCallback: SequentialCallback, callback: SimpleCallback, asArray?: boolean): Database;
commit(callback?: SimpleCallback): void;
commitRetaining(callback?: SimpleCallback): void;
rollback(callback?: SimpleCallback): void;
Expand Down
51 changes: 40 additions & 11 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,29 @@ Transaction.prototype.execute = function(query, params, callback, custom) {
});
};

Transaction.prototype.sequentially = function (query, params, on, callback, asArray) {

if (params instanceof Function) {
asArray = callback;
callback = on;
on = params;
params = undefined;
}

if (on === undefined){
throw new Error('Expected "on" delegate.');
}

if (callback instanceof Boolean) {
asArray = callback;
callback = undefined;
}

var self = this;
self.execute(query, params, callback, { asObject: !asArray, asStream: true, on: on });
return self;
};

Transaction.prototype.query = function(query, params, callback) {

if (params instanceof Function) {
Expand Down Expand Up @@ -1616,19 +1639,25 @@ Database.prototype.execute = function(query, params, callback, custom) {

Database.prototype.sequentially = function(query, params, on, callback, asArray) {

if (params instanceof Function) {
asArray = callback;
callback = on;
on = params;
params = undefined;
}
if (params instanceof Function) {
asArray = callback;
callback = on;
on = params;
params = undefined;
}

if (on === undefined){
throw new Error('Expected "on" delegate.');
}

if (on === undefined)
throw new Error('Expected "on" delegate.');
if (callback instanceof Boolean) {
asArray = callback;
callback = undefined;
}

var self = this;
self.execute(query, params, callback, { asObject: !asArray, asStream: true, on: on });
return self;
var self = this;
self.execute(query, params, callback, { asObject: !asArray, asStream: true, on: on });
return self;
};

Database.prototype.query = function(query, params, callback) {
Expand Down

0 comments on commit 3f62863

Please sign in to comment.