@cdellacqua/knex-transact
Advanced tools
Comparing version 4.1.0 to 5.0.0
@@ -1,4 +0,4 @@ | ||
import { Knex } from 'knex'; | ||
export declare type TransactionCode<T> = (trx: Knex.Transaction) => Promise<T>; | ||
export declare type NextTransactionCode<T = any> = (trx: Knex.Transaction, previousValue?: any) => Promise<T>; | ||
import { Knex } from "knex"; | ||
export type TransactionCode<T> = (trx: Knex.Transaction) => Promise<T>; | ||
export type NextTransactionCode<T = any> = (trx: Knex.Transaction, previousValue?: any) => Promise<T>; | ||
export declare const config: { | ||
@@ -5,0 +5,0 @@ knexInstance?: Knex; |
@@ -1,9 +0,6 @@ | ||
import { SerializableError } from '@cdellacqua/serializable-error'; | ||
const config = {}; | ||
async function transact(provider, trx) { | ||
var _a; | ||
const transaction = trx || await ((_a = config.knexInstance) === null || _a === void 0 ? void 0 : _a.transaction()); | ||
const transaction = trx || (await config.knexInstance?.transaction()); | ||
if (!transaction) { | ||
throw new Error('missing knex instance in config object, try assigning your knex instance to the config.knexInstance property of this package'); | ||
throw new Error("missing knex instance in config object, try assigning your knex instance to the config.knexInstance property of this package"); | ||
} | ||
@@ -28,3 +25,6 @@ const ownTransaction = !trx; | ||
} | ||
throw new SerializableError('an error occurred while executing the transaction' + (ownTransaction ? ', rolled back' : ''), err); | ||
throw new Error("an error occurred while executing the transaction" + | ||
(ownTransaction ? ", rolled back" : ""), { | ||
cause: err, | ||
}); | ||
} | ||
@@ -31,0 +31,0 @@ } |
{ | ||
"name": "@cdellacqua/knex-transact", | ||
"version": "4.1.0", | ||
"version": "5.0.0", | ||
"description": "transact function that provides a simple mechanism to translate SQL transactions into code", | ||
@@ -46,10 +46,7 @@ "types": "build/index.d.ts", | ||
"rollup": "^2.32.1", | ||
"typescript": "^4.2.4" | ||
"typescript": "^5.0.3" | ||
}, | ||
"peerDependencies": { | ||
"knex": "^1.0.3 || ^2.0.0" | ||
}, | ||
"dependencies": { | ||
"@cdellacqua/serializable-error": "^1.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
1
73
6677
- Removed@cdellacqua/serializable-error@1.1.4(transitive)