@ultimat3/db 26.1.0 → 27.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/transaction.ts +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/db",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "27.0.0",
|
|
4
4
|
"description": "Postgres access, transactions, migrations and drift detection",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test": "bun test"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@ultimat3/core": "
|
|
36
|
+
"@ultimat3/core": "27.0.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@electric-sql/pglite": ">=0.5.0"
|
package/src/index.ts
CHANGED
|
@@ -205,7 +205,7 @@ export { DB_SQLSTATE_CODES, isRetryableState, SQLSTATE, sqlState, sqlStateCode }
|
|
|
205
205
|
export { statementFingerprint, statementKind, statementVerb } from './statement-shape';
|
|
206
206
|
export { STATEMENT_ATTRIBUTE } from './statement-span';
|
|
207
207
|
export { statementsOf } from './statement-split';
|
|
208
|
-
export { currentTx, liveTxConnection, withTransaction } from './transaction';
|
|
208
|
+
export { currentTx, liveTxConnection, outsideTransaction, withTransaction } from './transaction';
|
|
209
209
|
export { commitUnknown, siblingScopeTimeout, transactionAborted } from './transaction-errors';
|
|
210
210
|
export type { DbTx, IsolationLevel, TransactionOptions } from './transaction-options';
|
|
211
211
|
export { beginStatement } from './transaction-options';
|
package/src/transaction.ts
CHANGED
|
@@ -79,6 +79,17 @@ export function currentTx(): DbTx | undefined {
|
|
|
79
79
|
return storage.get()?.tx;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Run `fn` outside any transaction this async context carries: inside it `currentTx()` is
|
|
84
|
+
* `undefined` and `db()` is the pool. For work that must never join a caller's transaction even
|
|
85
|
+
* when it was STARTED inside one — `@ultimat3/jobs` runs every job body under it, because a worker
|
|
86
|
+
* started inside a transaction scope handed each job that transaction, long committed, and an
|
|
87
|
+
* enqueue from the body staged into its dead outbox.
|
|
88
|
+
*/
|
|
89
|
+
export function outsideTransaction<R>(fn: () => R): R {
|
|
90
|
+
return storage.exit(fn);
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
/**
|
|
83
94
|
* The connection the transaction still OPEN on this async context runs on, or `undefined`. A
|
|
84
95
|
* different question from `currentTx() !== undefined`, which only says a store is present — and the
|