mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 08:17:05 +00:00
Quote from Knex source code comments: 'The transactor is a full featured knex object, with a "commit", a "rollback" and a "savepoint" function.' (#16092)
This commit is contained in:
committed by
Sheetal Nandi
parent
1b25b92cff
commit
de52c9ccca
Vendored
+5
-5
@@ -22,7 +22,7 @@ interface Knex extends Knex.QueryInterface {
|
||||
__knex__: string;
|
||||
|
||||
raw: Knex.RawBuilder;
|
||||
transaction: <R>(transactionScope: ((trx: Knex.Transaction) => void)) => Promise<any>;
|
||||
transaction(transactionScope: (trx: Knex.Transaction) => any): Promise<any>;
|
||||
destroy(callback: Function): void;
|
||||
destroy(): Promise<void>;
|
||||
batchInsert(tableName : TableName, data: any[], chunkSize : number) : Knex.QueryBuilder;
|
||||
@@ -347,10 +347,10 @@ declare namespace Knex {
|
||||
exec(callback: Function): QueryBuilder;
|
||||
}
|
||||
|
||||
interface Transaction extends QueryBuilder {
|
||||
commit: any;
|
||||
rollback: any;
|
||||
raw: Knex.RawBuilder;
|
||||
interface Transaction extends Knex {
|
||||
savepoint(transactionScope: (trx: Transaction) => any): Promise<any>;
|
||||
commit(value?: any): QueryBuilder;
|
||||
rollback(error?: any): QueryBuilder;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -434,7 +434,19 @@ knex.transaction(function(trx) {
|
||||
// Using trx as a transaction object:
|
||||
knex.transaction(function(trx) {
|
||||
|
||||
trx.raw('')
|
||||
trx.raw('');
|
||||
|
||||
trx.on('query-error', function(error: Error) {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
trx.savepoint(function(nestedTrx) {
|
||||
nestedTrx.rollback(new Error('something went terribly wrong'));
|
||||
});
|
||||
|
||||
trx.transaction(function(nestedTrx) {
|
||||
nestedTrx.commit();
|
||||
});
|
||||
|
||||
var info: any;
|
||||
var books: any[] = [
|
||||
|
||||
Reference in New Issue
Block a user