@zukhruf/sqlite-transaction 0.8.43 → 0.8.44

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.
Files changed (2) hide show
  1. package/README.md +15 -0
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -79,6 +79,21 @@ stop
79
79
  | Python `sqlite3` | `with conn:` commits when the block ends, and rolls back when the block raises an exception. |
80
80
  | SQLite automatic rollback | After some errors, for example `SQLITE_IOERR` or `RAISE(ROLLBACK)` in a trigger, SQLite rolls back the transaction itself. See "Response To Errors Within A Transaction" in the SQLite documentation. |
81
81
 
82
+ ## API
83
+
84
+ ```ts
85
+ // When a transaction that the call owns starts, and so when it takes the write lock.
86
+ type TransactionMode = 'deferred' | 'immediate' | 'exclusive';
87
+
88
+ // A DatabaseSync of node:sqlite fits the database parameter.
89
+ // A work that gives a promise has the return type never, so TypeScript refuses it.
90
+ function transaction<T>(
91
+ database: Pick<DatabaseSync, 'exec' | 'isTransaction'>,
92
+ work: () => T extends PromiseLike<unknown> ? never : T,
93
+ options: { readonly mode: TransactionMode },
94
+ ): T;
95
+ ```
96
+
82
97
  ## Documentation
83
98
 
84
99
  - [0001 Roll back only while SQLite holds the transaction](./docs/adr/0001-roll-back-only-while-sqlite-holds-the-transaction.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/sqlite-transaction",
3
- "version": "0.8.43",
3
+ "version": "0.8.44",
4
4
  "description": "A transaction function for node:sqlite: it commits when the function returns and rolls back when it throws. A nested call uses a savepoint. When SQLite ends the transaction itself, the caller gets the original error, not \"cannot rollback\".",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,8 +40,8 @@
40
40
  "access": "public"
41
41
  },
42
42
  "devDependencies": {
43
- "@zukhruf/fs": "^0.8.43",
44
- "@zukhruf/sqlite-open": "^0.8.43",
45
- "@zukhruf/testing": "^0.8.43"
43
+ "@zukhruf/fs": "^0.8.44",
44
+ "@zukhruf/sqlite-open": "^0.8.44",
45
+ "@zukhruf/testing": "^0.8.44"
46
46
  }
47
47
  }