@stacksjs/orm 0.75.569 → 0.75.571

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.
@@ -10,15 +10,26 @@ import { db } from '@stacksjs/database/runtime';
10
10
  * not rebound to this handle, so `User.find()` or an instance relation call
11
11
  * inside the callback cannot be assumed to observe uncommitted `tx` writes.
12
12
  *
13
+ * It is done when it returns: BEGIN, the callback and COMMIT have happened by
14
+ * the next line, and what the callback returned is the result. A callback that
15
+ * is `async` is waited for, and the transaction is then a promise.
16
+ *
13
17
  * @example
14
18
  * ```ts
19
+ * const userId = transaction((tx) => {
20
+ * const user = tx.insertInto('users').values({ name: 'Alice' }).returning('id').first()
21
+ * tx.insertInto('profiles').values({ user_id: user.id }).execute()
22
+ * return user.id
23
+ * })
24
+ *
25
+ * // An async callback, awaited as before:
15
26
  * await transaction(async (tx) => {
16
27
  * await tx.insertInto('users').values({ name: 'Alice' }).execute()
17
- * await tx.insertInto('profiles').values({ user_id: 1 }).execute()
28
+ * await notifyBilling()
18
29
  * })
19
30
  * ```
20
31
  */
21
- export declare function transaction<T>(callback: (tx: TransactionHandle) => Promise<T>, options?: TransactionOptions): Promise<T>;
32
+ export declare function transaction<T>(callback: (tx: TransactionHandle) => T, options?: TransactionOptions): T;
22
33
  /**
23
34
  * Create a savepoint within a transaction for nested rollback support.
24
35
  *
@@ -34,7 +45,7 @@ export declare function transaction<T>(callback: (tx: TransactionHandle) => Prom
34
45
  * })
35
46
  * ```
36
47
  */
37
- export declare function savepoint<T>(callback: (sp: TransactionHandle) => Promise<T>): Promise<T>;
48
+ export declare function savepoint<T>(callback: (sp: TransactionHandle) => T): T;
38
49
  /**
39
50
  * Wrap a function to automatically run within a transaction when called.
40
51
  *
@@ -50,7 +61,7 @@ export declare function savepoint<T>(callback: (sp: TransactionHandle) => Promis
50
61
  * const user = await createUserWithProfile('Alice', 'Hello world')
51
62
  * ```
52
63
  */
53
- export declare function transactional<TArgs extends unknown[], R>(fn: (tx: TransactionHandle, ...args: TArgs) => Promise<R>, options?: TransactionOptions): (...args: TArgs) => Promise<R>;
64
+ export declare function transactional<TArgs extends unknown[], R>(fn: (tx: TransactionHandle, ...args: TArgs) => R, options?: TransactionOptions): (...args: TArgs) => R;
54
65
  export declare interface TransactionOptions {
55
66
  retries?: number
56
67
  isolation?: 'read committed' | 'repeatable read' | 'serializable'
@@ -1 +1 @@
1
- import{db}from"@stacksjs/database/runtime";export async function transaction(callback,options){return await db.transaction(callback,options)}export async function savepoint(callback){return await db.savepoint(callback)}export function transactional(fn,options){return db.transactional(fn,options)}
1
+ import{db}from"@stacksjs/database/runtime";export function transaction(callback,options){return db.transaction(callback,options)}export function savepoint(callback){return db.savepoint(callback)}export function transactional(fn,options){return db.transactional(fn,options)}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/orm",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.569",
5
+ "version": "0.75.571",
6
6
  "description": "The Stacks ORM integration",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -63,32 +63,32 @@
63
63
  "prepublishOnly": "bun run build"
64
64
  },
65
65
  "dependencies": {
66
- "@stacksjs/cache": "0.75.569",
67
- "@stacksjs/cli": "0.75.569",
68
- "@stacksjs/config": "0.75.569",
69
- "@stacksjs/database": "0.75.569",
70
- "@stacksjs/env": "0.75.569",
71
- "@stacksjs/error-handling": "0.75.569",
72
- "@stacksjs/events": "0.75.569",
73
- "@stacksjs/logging": "0.75.569",
74
- "@stacksjs/model-meta": "0.75.569",
75
- "@stacksjs/pagination": "0.75.569",
76
- "@stacksjs/path": "0.75.569",
77
- "@stacksjs/query-builder": "0.75.569",
78
- "@stacksjs/realtime": "0.75.569",
79
- "@stacksjs/router": "0.75.569",
80
- "@stacksjs/storage": "0.75.569",
81
- "@stacksjs/strings": "0.75.569",
66
+ "@stacksjs/cache": "0.75.571",
67
+ "@stacksjs/cli": "0.75.571",
68
+ "@stacksjs/config": "0.75.571",
69
+ "@stacksjs/database": "0.75.571",
70
+ "@stacksjs/env": "0.75.571",
71
+ "@stacksjs/error-handling": "0.75.571",
72
+ "@stacksjs/events": "0.75.571",
73
+ "@stacksjs/logging": "0.75.571",
74
+ "@stacksjs/model-meta": "0.75.571",
75
+ "@stacksjs/pagination": "0.75.571",
76
+ "@stacksjs/path": "0.75.571",
77
+ "@stacksjs/query-builder": "0.75.571",
78
+ "@stacksjs/realtime": "0.75.571",
79
+ "@stacksjs/router": "0.75.571",
80
+ "@stacksjs/storage": "0.75.571",
81
+ "@stacksjs/strings": "0.75.571",
82
82
  "@stacksjs/ts-validation": "^0.5.7",
83
- "@stacksjs/validation": "0.75.569",
84
- "bun-query-builder": "^0.4.2",
83
+ "@stacksjs/validation": "0.75.571",
84
+ "bun-query-builder": "^0.5.2",
85
85
  "stripe": "23.0.0"
86
86
  },
87
87
  "peerDependencies": {
88
- "@stacksjs/auth": "0.75.569",
89
- "@stacksjs/payments": "0.75.569",
90
- "@stacksjs/queue": "0.75.569",
91
- "@stacksjs/search-engine": "0.75.569"
88
+ "@stacksjs/auth": "0.75.571",
89
+ "@stacksjs/payments": "0.75.571",
90
+ "@stacksjs/queue": "0.75.571",
91
+ "@stacksjs/search-engine": "0.75.571"
92
92
  },
93
93
  "peerDependenciesMeta": {
94
94
  "@stacksjs/auth": {
@@ -102,7 +102,7 @@
102
102
  }
103
103
  },
104
104
  "devDependencies": {
105
- "@stacksjs/types": "0.75.569",
105
+ "@stacksjs/types": "0.75.571",
106
106
  "better-dx": "^0.2.24"
107
107
  }
108
108
  }