turbine-orm 0.50.0 → 0.51.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/README.md +66 -66
- package/dist/adapters/cockroachdb.d.ts +5 -5
- package/dist/adapters/cockroachdb.js +10 -10
- package/dist/adapters/index.d.ts +5 -5
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/yugabytedb.d.ts +7 -7
- package/dist/adapters/yugabytedb.js +10 -10
- package/dist/cjs/adapters/cockroachdb.d.ts +5 -5
- package/dist/cjs/adapters/cockroachdb.js +10 -10
- package/dist/cjs/adapters/index.d.ts +5 -5
- package/dist/cjs/adapters/index.js +7 -7
- package/dist/cjs/adapters/yugabytedb.d.ts +7 -7
- package/dist/cjs/adapters/yugabytedb.js +10 -10
- package/dist/cjs/cli/config.d.ts +13 -2
- package/dist/cjs/cli/config.js +3 -2
- package/dist/cjs/cli/destructive.d.ts +1 -1
- package/dist/cjs/cli/destructive.js +1 -1
- package/dist/cjs/cli/index.d.ts +10 -10
- package/dist/cjs/cli/index.js +49 -45
- package/dist/cjs/cli/loader.d.ts +7 -7
- package/dist/cjs/cli/loader.js +9 -9
- package/dist/cjs/cli/mcp.js +4 -4
- package/dist/cjs/cli/migrate.d.ts +5 -5
- package/dist/cjs/cli/migrate.js +11 -11
- package/dist/cjs/cli/studio-ui.generated.js +1 -1
- package/dist/cjs/cli/ui.d.ts +2 -2
- package/dist/cjs/cli/ui.js +2 -2
- package/dist/cjs/client.d.ts +49 -38
- package/dist/cjs/client.js +57 -56
- package/dist/cjs/dialect.d.ts +62 -18
- package/dist/cjs/dialect.js +40 -2
- package/dist/cjs/errors.d.ts +5 -5
- package/dist/cjs/errors.js +11 -11
- package/dist/cjs/generate.d.ts +6 -6
- package/dist/cjs/generate.js +31 -29
- package/dist/cjs/index-advisor.d.ts +5 -5
- package/dist/cjs/index-advisor.js +0 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/introspect.d.ts +35 -9
- package/dist/cjs/introspect.js +83 -32
- package/dist/cjs/mssql.d.ts +11 -11
- package/dist/cjs/mssql.js +64 -29
- package/dist/cjs/mysql.d.ts +8 -8
- package/dist/cjs/mysql.js +61 -23
- package/dist/cjs/nested-write.d.ts +21 -2
- package/dist/cjs/nested-write.js +51 -14
- package/dist/cjs/optional-peer-import.cjs +7 -7
- package/dist/cjs/optional-peer-import.d.cts +7 -7
- package/dist/cjs/pipeline-submittable.d.ts +2 -2
- package/dist/cjs/pipeline-submittable.js +6 -6
- package/dist/cjs/pipeline.d.ts +1 -1
- package/dist/cjs/pipeline.js +4 -4
- package/dist/cjs/powdb-introspect.d.ts +1 -1
- package/dist/cjs/powdb-introspect.js +1 -1
- package/dist/cjs/powdb.d.ts +28 -28
- package/dist/cjs/powdb.js +66 -66
- package/dist/cjs/powql.d.ts +27 -27
- package/dist/cjs/powql.js +73 -52
- package/dist/cjs/query/aggregates.d.ts +1 -1
- package/dist/cjs/query/aggregates.js +5 -5
- package/dist/cjs/query/batched-loader.d.ts +11 -11
- package/dist/cjs/query/batched-loader.js +24 -24
- package/dist/cjs/query/builder.d.ts +39 -21
- package/dist/cjs/query/builder.js +99 -57
- package/dist/cjs/query/compound-unique.d.ts +1 -1
- package/dist/cjs/query/compound-unique.js +0 -0
- package/dist/cjs/query/deferred.d.ts +12 -6
- package/dist/cjs/query/deferred.js +1 -1
- package/dist/cjs/query/filters.d.ts +31 -11
- package/dist/cjs/query/filters.js +67 -14
- package/dist/cjs/query/index.d.ts +1 -1
- package/dist/cjs/query/index.js +1 -1
- package/dist/cjs/query/relations.d.ts +9 -9
- package/dist/cjs/query/relations.js +164 -57
- package/dist/cjs/query/types.d.ts +86 -35
- package/dist/cjs/query/types.js +1 -1
- package/dist/cjs/query/utils.d.ts +27 -10
- package/dist/cjs/query/utils.js +86 -14
- package/dist/cjs/query/where.d.ts +47 -28
- package/dist/cjs/query/where.js +130 -31
- package/dist/cjs/query/writes.d.ts +24 -5
- package/dist/cjs/query/writes.js +102 -13
- package/dist/cjs/realtime.d.ts +7 -7
- package/dist/cjs/realtime.js +9 -9
- package/dist/cjs/schema-builder.d.ts +18 -7
- package/dist/cjs/schema-builder.js +17 -10
- package/dist/cjs/schema-metadata.d.ts +3 -3
- package/dist/cjs/schema-metadata.js +9 -9
- package/dist/cjs/schema-sql.d.ts +9 -9
- package/dist/cjs/schema-sql.js +20 -20
- package/dist/cjs/schema.d.ts +19 -9
- package/dist/cjs/schema.js +6 -6
- package/dist/cjs/serverless.d.ts +15 -15
- package/dist/cjs/serverless.js +16 -16
- package/dist/cjs/sqlite.d.ts +8 -8
- package/dist/cjs/sqlite.js +53 -22
- package/dist/cjs/typed-sql.d.ts +4 -4
- package/dist/cjs/typed-sql.js +5 -5
- package/dist/cli/config.d.ts +13 -2
- package/dist/cli/config.js +3 -2
- package/dist/cli/destructive.d.ts +1 -1
- package/dist/cli/destructive.js +1 -1
- package/dist/cli/index.d.ts +10 -10
- package/dist/cli/index.js +49 -45
- package/dist/cli/loader.d.ts +7 -7
- package/dist/cli/loader.js +9 -9
- package/dist/cli/mcp.js +4 -4
- package/dist/cli/migrate.d.ts +5 -5
- package/dist/cli/migrate.js +11 -11
- package/dist/cli/studio-ui.generated.js +1 -1
- package/dist/cli/ui.d.ts +2 -2
- package/dist/cli/ui.js +2 -2
- package/dist/client.d.ts +49 -38
- package/dist/client.js +57 -56
- package/dist/dialect.d.ts +62 -18
- package/dist/dialect.js +40 -2
- package/dist/errors.d.ts +5 -5
- package/dist/errors.js +11 -11
- package/dist/generate.d.ts +6 -6
- package/dist/generate.js +31 -29
- package/dist/index-advisor.d.ts +5 -5
- package/dist/index-advisor.js +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/introspect.d.ts +35 -9
- package/dist/introspect.js +82 -32
- package/dist/mssql.d.ts +11 -11
- package/dist/mssql.js +64 -29
- package/dist/mysql.d.ts +8 -8
- package/dist/mysql.js +61 -23
- package/dist/nested-write.d.ts +21 -2
- package/dist/nested-write.js +51 -14
- package/dist/optional-peer-import.cjs +7 -7
- package/dist/optional-peer-import.d.cts +7 -7
- package/dist/pipeline-submittable.d.ts +2 -2
- package/dist/pipeline-submittable.js +6 -6
- package/dist/pipeline.d.ts +1 -1
- package/dist/pipeline.js +4 -4
- package/dist/powdb-introspect.d.ts +1 -1
- package/dist/powdb-introspect.js +1 -1
- package/dist/powdb.d.ts +28 -28
- package/dist/powdb.js +66 -66
- package/dist/powql.d.ts +27 -27
- package/dist/powql.js +73 -52
- package/dist/query/aggregates.d.ts +1 -1
- package/dist/query/aggregates.js +5 -5
- package/dist/query/batched-loader.d.ts +11 -11
- package/dist/query/batched-loader.js +24 -24
- package/dist/query/builder.d.ts +39 -21
- package/dist/query/builder.js +100 -58
- package/dist/query/compound-unique.d.ts +1 -1
- package/dist/query/compound-unique.js +0 -0
- package/dist/query/deferred.d.ts +12 -6
- package/dist/query/deferred.js +1 -1
- package/dist/query/filters.d.ts +31 -11
- package/dist/query/filters.js +66 -13
- package/dist/query/index.d.ts +1 -1
- package/dist/query/index.js +1 -1
- package/dist/query/relations.d.ts +9 -9
- package/dist/query/relations.js +165 -58
- package/dist/query/types.d.ts +86 -35
- package/dist/query/types.js +1 -1
- package/dist/query/utils.d.ts +27 -10
- package/dist/query/utils.js +84 -14
- package/dist/query/where.d.ts +47 -28
- package/dist/query/where.js +129 -32
- package/dist/query/writes.d.ts +24 -5
- package/dist/query/writes.js +101 -13
- package/dist/realtime.d.ts +7 -7
- package/dist/realtime.js +9 -9
- package/dist/schema-builder.d.ts +18 -7
- package/dist/schema-builder.js +17 -10
- package/dist/schema-metadata.d.ts +3 -3
- package/dist/schema-metadata.js +9 -9
- package/dist/schema-sql.d.ts +9 -9
- package/dist/schema-sql.js +20 -20
- package/dist/schema.d.ts +19 -9
- package/dist/schema.js +6 -6
- package/dist/serverless.d.ts +15 -15
- package/dist/serverless.js +16 -16
- package/dist/sqlite.d.ts +8 -8
- package/dist/sqlite.js +53 -22
- package/dist/typed-sql.d.ts +4 -4
- package/dist/typed-sql.js +5 -5
- package/package.json +2 -2
package/dist/cjs/cli/ui.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* turbine-orm CLI
|
|
2
|
+
* turbine-orm CLI, UI utilities
|
|
3
3
|
*
|
|
4
4
|
* ANSI colors, spinners, box-drawing, and formatting helpers.
|
|
5
|
-
* Zero dependencies
|
|
5
|
+
* Zero dependencies, raw escape codes only.
|
|
6
6
|
*/
|
|
7
7
|
export declare const bold: (s: string) => string;
|
|
8
8
|
export declare const dim: (s: string) => string;
|
package/dist/cjs/cli/ui.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* turbine-orm CLI
|
|
3
|
+
* turbine-orm CLI, UI utilities
|
|
4
4
|
*
|
|
5
5
|
* ANSI colors, spinners, box-drawing, and formatting helpers.
|
|
6
|
-
* Zero dependencies
|
|
6
|
+
* Zero dependencies, raw escape codes only.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Spinner = exports.symbols = exports.bgCyan = exports.bgYellow = exports.bgRed = exports.bgGreen = exports.redBright = exports.yellowBright = exports.cyanBright = exports.greenBright = exports.gray = exports.white = exports.cyan = exports.magenta = exports.blue = exports.yellow = exports.green = exports.red = exports.underline = exports.italic = exports.dim = exports.bold = void 0;
|
package/dist/cjs/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* turbine-orm
|
|
2
|
+
* turbine-orm, TurbineClient
|
|
3
3
|
*
|
|
4
4
|
* The main entry point for the Turbine TypeScript SDK.
|
|
5
5
|
* Manages connection pooling and provides typed table accessors.
|
|
@@ -84,7 +84,7 @@ export interface PgCompatPoolClient {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Minimal pg-compatible pool. Pass any driver that satisfies this interface
|
|
87
|
-
* via `TurbineConfig.pool
|
|
87
|
+
* via `TurbineConfig.pool`, lets Turbine run on Neon HTTP, Vercel Postgres,
|
|
88
88
|
* Cloudflare Hyperdrive, or any other serverless Postgres driver.
|
|
89
89
|
*
|
|
90
90
|
* @example
|
|
@@ -100,16 +100,16 @@ export interface PgCompatPool {
|
|
|
100
100
|
query<R = Record<string, unknown>>(text: string, values?: unknown[]): Promise<PgCompatQueryResult<R>>;
|
|
101
101
|
connect(): Promise<PgCompatPoolClient>;
|
|
102
102
|
end(): Promise<void>;
|
|
103
|
-
/** Optional
|
|
103
|
+
/** Optional, pools that expose stats (pg.Pool does; Neon HTTP does not) */
|
|
104
104
|
readonly totalCount?: number;
|
|
105
105
|
readonly idleCount?: number;
|
|
106
106
|
readonly waitingCount?: number;
|
|
107
|
-
/** Optional
|
|
107
|
+
/** Optional, pg.Pool supports 'error' event; HTTP drivers typically do not */
|
|
108
108
|
on?(event: 'error', listener: (err: Error) => void): this;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Driver-neutral seam. Bundles a pg-compatible connection pool with the SQL
|
|
112
|
-
* {@link Dialect} that owns every piece of SQL text varying across engines
|
|
112
|
+
* {@link Dialect} that owns every piece of SQL text varying across engines -
|
|
113
113
|
* parameter placeholders, transaction-control keywords (BEGIN/COMMIT/ROLLBACK/
|
|
114
114
|
* SAVEPOINT/isolation/set_config), streaming, and capability flags.
|
|
115
115
|
*
|
|
@@ -175,7 +175,7 @@ export interface TurbineConfig {
|
|
|
175
175
|
*/
|
|
176
176
|
warnOnUnlimited?: boolean | Record<string, boolean>;
|
|
177
177
|
/**
|
|
178
|
-
* Interpret Postgres `timestamp` (without time zone) values as UTC
|
|
178
|
+
* Interpret Postgres `timestamp` (without time zone) values as UTC, both
|
|
179
179
|
* at the driver level (OID 1114 type parser, registered only when Turbine
|
|
180
180
|
* owns the pool) and when coercing nested-relation JSON dates. This is the
|
|
181
181
|
* Prisma/Rails/Django convention and makes results independent of the
|
|
@@ -183,6 +183,17 @@ export interface TurbineConfig {
|
|
|
183
183
|
* local-time interpretation.
|
|
184
184
|
*/
|
|
185
185
|
utcTimestamps?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Refuse a nested `connect` / `connectOrCreate` that would re-parent a
|
|
188
|
+
* to-many child already owned by a different parent. Off by default,
|
|
189
|
+
* because it changes the outcome of writes that currently succeed.
|
|
190
|
+
*
|
|
191
|
+
* Worth turning on for any multi-tenant application: without it, a handler
|
|
192
|
+
* that forwards a client-supplied id into a nested connect lets a caller
|
|
193
|
+
* take another tenant's row. See
|
|
194
|
+
* {@link import('./nested-write.js').NestedWriteContext.scopedConnect}.
|
|
195
|
+
*/
|
|
196
|
+
scopedConnect?: boolean;
|
|
186
197
|
/**
|
|
187
198
|
* Default strategy for resolving `with`-clause relations, applied to every
|
|
188
199
|
* `findMany`/`findUnique`/`findFirst` unless overridden per query.
|
|
@@ -259,9 +270,9 @@ export interface TurbineConfig {
|
|
|
259
270
|
/**
|
|
260
271
|
* How nested-relation subqueries encode each row's JSON.
|
|
261
272
|
*
|
|
262
|
-
* - `'object'` (default)
|
|
273
|
+
* - `'object'` (default), `json_agg(json_build_object('key', v, …))`. Every
|
|
263
274
|
* key name is repeated in every nested object of every row.
|
|
264
|
-
* - `'positional'
|
|
275
|
+
* - `'positional'`, `json_agg(json_build_array(v, …))`. Turbine knows the
|
|
265
276
|
* column order at build time, so it emits a key-less array and maps
|
|
266
277
|
* positions back to keys client-side. Same information, a fraction of the
|
|
267
278
|
* bytes on wide/deeply-nested `with` trees. Parsed output is byte-identical
|
|
@@ -323,16 +334,16 @@ export interface TurbineConfig {
|
|
|
323
334
|
* `$transaction` bodies, `pipeline`, `raw`/`sql`, `$listen`/`$notify`, and
|
|
324
335
|
* observability flushes always use the primary.
|
|
325
336
|
*
|
|
326
|
-
* - `string` entries are connection strings
|
|
337
|
+
* - `string` entries are connection strings, Turbine constructs an owned
|
|
327
338
|
* `pg.Pool` for each (same pool-tuning knobs as the primary, and the same
|
|
328
339
|
* one-time, constructor-gated type-parser registration). `disconnect()`
|
|
329
340
|
* closes them.
|
|
330
341
|
* - `PgCompatPool` entries are external pools (Neon, Vercel, a shared
|
|
331
|
-
* `pg.Pool`)
|
|
342
|
+
* `pg.Pool`), Turbine registers no type parsers on them and never ends
|
|
332
343
|
* them; the caller owns their lifecycle.
|
|
333
344
|
*
|
|
334
345
|
* Use `client.$primary()` to get a view of the client that pins every
|
|
335
|
-
* operation (reads included) to the primary
|
|
346
|
+
* operation (reads included) to the primary, e.g. to read your own write
|
|
336
347
|
* without replication lag. Omitting `replicas` (or passing `[]`) leaves the
|
|
337
348
|
* default single-pool path completely unchanged.
|
|
338
349
|
*/
|
|
@@ -340,8 +351,8 @@ export interface TurbineConfig {
|
|
|
340
351
|
/**
|
|
341
352
|
* Automatic WHERE filters applied to every query, keyed by table accessor
|
|
342
353
|
* (`db[name]`). Each value is AND-merged into the compiled WHERE of every
|
|
343
|
-
* read and mutation on that table
|
|
344
|
-
* targets it
|
|
354
|
+
* read and mutation on that table, and into every relation subquery that
|
|
355
|
+
* targets it, implementing soft-delete and multi-tenancy without repeating
|
|
345
356
|
* the predicate at each call site.
|
|
346
357
|
*
|
|
347
358
|
* - A `WhereClause` value is a static filter (e.g. `{ deletedAt: null }`).
|
|
@@ -378,7 +389,7 @@ export type MiddlewareNext = (params: MiddlewareParams) => Promise<unknown>;
|
|
|
378
389
|
/** A middleware function that intercepts queries */
|
|
379
390
|
export type Middleware = (params: MiddlewareParams, next: MiddlewareNext) => Promise<unknown>;
|
|
380
391
|
export interface TransactionOptions {
|
|
381
|
-
/** Timeout in ms
|
|
392
|
+
/** Timeout in ms, transaction will be rolled back if exceeded */
|
|
382
393
|
timeout?: number;
|
|
383
394
|
/** Isolation level for the transaction */
|
|
384
395
|
isolationLevel?: 'ReadUncommitted' | 'ReadCommitted' | 'RepeatableRead' | 'Serializable';
|
|
@@ -388,7 +399,7 @@ export interface TransactionOptions {
|
|
|
388
399
|
* `current_setting('app.current_tenant')`, and you set that value here so
|
|
389
400
|
* every query inside the transaction sees it.
|
|
390
401
|
*
|
|
391
|
-
* Each entry is applied via `SELECT set_config($1, $2, true)
|
|
402
|
+
* Each entry is applied via `SELECT set_config($1, $2, true)`, `is_local=true`
|
|
392
403
|
* scopes the value to this transaction, so it auto-resets on COMMIT/ROLLBACK
|
|
393
404
|
* and never leaks onto the pooled connection. Both the name and value are
|
|
394
405
|
* bound parameters (never interpolated); the GUC name is additionally
|
|
@@ -429,7 +440,7 @@ export declare class TransactionClient {
|
|
|
429
440
|
private readonly sourcePool?;
|
|
430
441
|
private readonly tableCache;
|
|
431
442
|
private savepointCounter;
|
|
432
|
-
/** Active SQL dialect
|
|
443
|
+
/** Active SQL dialect, owns savepoint keywords and raw-SQL placeholders. */
|
|
433
444
|
private readonly dialect;
|
|
434
445
|
constructor(client: pg.PoolClient, schema: SchemaMetadata, middlewares: Middleware[], queryOptions?: QueryInterfaceOptions | undefined,
|
|
435
446
|
/**
|
|
@@ -471,14 +482,14 @@ export declare class TransactionClient {
|
|
|
471
482
|
private createTxPool;
|
|
472
483
|
}
|
|
473
484
|
export declare class TurbineClient {
|
|
474
|
-
/** The underlying pg.Pool
|
|
485
|
+
/** The underlying pg.Pool, exposed for escape hatches */
|
|
475
486
|
readonly pool: pg.Pool;
|
|
476
487
|
/** The schema metadata this client was built from */
|
|
477
488
|
readonly schema: SchemaMetadata;
|
|
478
489
|
private static int8ParserRegistered;
|
|
479
490
|
private static utcTimestampParserRegistered;
|
|
480
491
|
private readonly logging;
|
|
481
|
-
/** Active SQL dialect
|
|
492
|
+
/** Active SQL dialect, owns transaction keywords, set_config, raw-SQL placeholders, capability flags. */
|
|
482
493
|
private readonly dialect;
|
|
483
494
|
private readonly tableCache;
|
|
484
495
|
private readonly middlewares;
|
|
@@ -487,7 +498,7 @@ export declare class TurbineClient {
|
|
|
487
498
|
private readonly errorMessagesSafe;
|
|
488
499
|
/** True when Turbine created the pool and is responsible for tearing it down */
|
|
489
500
|
private readonly ownsPool;
|
|
490
|
-
/** Active LISTEN subscriptions
|
|
501
|
+
/** Active LISTEN subscriptions, torn down on disconnect() so it never hangs */
|
|
491
502
|
private readonly activeSubscriptions;
|
|
492
503
|
/**
|
|
493
504
|
* Read-replica pools in round-robin order. Empty when no replicas are
|
|
@@ -514,7 +525,7 @@ export declare class TurbineClient {
|
|
|
514
525
|
*
|
|
515
526
|
* Middleware can inspect and log query parameters, measure timing, and
|
|
516
527
|
* transform the result returned by `next()`. Note: query SQL is generated
|
|
517
|
-
* BEFORE middleware runs
|
|
528
|
+
* BEFORE middleware runs, `params.args` is a read-only snapshot, and
|
|
518
529
|
* mutating it does NOT change the executed SQL. Cross-cutting filters
|
|
519
530
|
* (e.g. soft deletes) belong in the query itself: pass an explicit
|
|
520
531
|
* `where: { deletedAt: null }` or wrap the table accessor in a small helper.
|
|
@@ -529,7 +540,7 @@ export declare class TurbineClient {
|
|
|
529
540
|
* return result;
|
|
530
541
|
* });
|
|
531
542
|
*
|
|
532
|
-
* // Result transformation middleware
|
|
543
|
+
* // Result transformation middleware, redact a field on the way out
|
|
533
544
|
* db.$use(async (params, next) => {
|
|
534
545
|
* const result = await next(params);
|
|
535
546
|
* if (params.model === 'users' && Array.isArray(result)) {
|
|
@@ -546,12 +557,12 @@ export declare class TurbineClient {
|
|
|
546
557
|
$observe(config: ObserveConfig): Promise<ObserveHandle>;
|
|
547
558
|
/**
|
|
548
559
|
* Get a QueryInterface for a table.
|
|
549
|
-
* Results are cached
|
|
560
|
+
* Results are cached, calling `table('users')` twice returns the same instance.
|
|
550
561
|
*
|
|
551
562
|
* When read replicas are configured, this returns a thin routing proxy: the
|
|
552
563
|
* read-only operations in {@link READ_OPERATIONS} are dispatched to a
|
|
553
|
-
* round-robin replica-bound QueryInterface (so an entire read
|
|
554
|
-
* any batched sub-queries
|
|
564
|
+
* round-robin replica-bound QueryInterface (so an entire read, base rows and
|
|
565
|
+
* any batched sub-queries, runs against a single consistent replica), while
|
|
555
566
|
* writes and every other member fall through to the primary-bound instance.
|
|
556
567
|
* With no replicas the original single-pool instance is returned directly.
|
|
557
568
|
*/
|
|
@@ -572,7 +583,7 @@ export declare class TurbineClient {
|
|
|
572
583
|
*/
|
|
573
584
|
private createRoutingAccessor;
|
|
574
585
|
/**
|
|
575
|
-
* Return a view of this client that pins EVERY operation
|
|
586
|
+
* Return a view of this client that pins EVERY operation, reads included -
|
|
576
587
|
* to the primary pool, bypassing replica routing. Use it to read your own
|
|
577
588
|
* write without replication lag, or for any read that must see the latest
|
|
578
589
|
* committed data.
|
|
@@ -580,7 +591,7 @@ export declare class TurbineClient {
|
|
|
580
591
|
* The view shares the primary pool, schema, dialect, query options, and
|
|
581
592
|
* middleware; it owns nothing, so its `disconnect()` is a no-op. When no
|
|
582
593
|
* replicas are configured this simply returns the client itself (already
|
|
583
|
-
* primary-only). The view is cached
|
|
594
|
+
* primary-only). The view is cached, repeated calls return the same instance.
|
|
584
595
|
*
|
|
585
596
|
* @example
|
|
586
597
|
* ```ts
|
|
@@ -594,8 +605,8 @@ export declare class TurbineClient {
|
|
|
594
605
|
* Execute multiple queries in a single database round-trip.
|
|
595
606
|
*
|
|
596
607
|
* Two call styles:
|
|
597
|
-
* - `db.pipeline(q1, q2, q3)
|
|
598
|
-
* - `db.pipeline([q1, q2, q3], { transactional: false })
|
|
608
|
+
* - `db.pipeline(q1, q2, q3)`, rest params (backward-compatible)
|
|
609
|
+
* - `db.pipeline([q1, q2, q3], { transactional: false })`, array + options
|
|
599
610
|
*
|
|
600
611
|
* On pg.Pool-backed connections with TCP, this uses the real Postgres
|
|
601
612
|
* extended-query pipeline protocol (one TCP flush, one round-trip).
|
|
@@ -622,7 +633,7 @@ export declare class TurbineClient {
|
|
|
622
633
|
*/
|
|
623
634
|
raw<T extends Record<string, unknown> = Record<string, unknown>>(strings: TemplateStringsArray, ...values: unknown[]): Promise<T[]>;
|
|
624
635
|
/**
|
|
625
|
-
* Execute a **typed** raw SQL query
|
|
636
|
+
* Execute a **typed** raw SQL query, Turbine's answer to Prisma's TypedSQL.
|
|
626
637
|
*
|
|
627
638
|
* Like {@link raw}, every interpolated `${value}` becomes a `$N` parameter
|
|
628
639
|
* (never string-concatenated), so it is injection-safe by construction. The
|
|
@@ -630,7 +641,7 @@ export declare class TurbineClient {
|
|
|
630
641
|
* returned {@link TypedSqlQuery} can be `await`ed directly for `T[]`, or
|
|
631
642
|
* refined with `.one()` (→ `T | null`) or `.scalar<V>()` (→ `V | null`).
|
|
632
643
|
*
|
|
633
|
-
* Rows are returned as-is
|
|
644
|
+
* Rows are returned as-is, no snake→camel mapping (matching `raw()`). Alias
|
|
634
645
|
* columns in SQL if you want camelCase keys.
|
|
635
646
|
*
|
|
636
647
|
* @example
|
|
@@ -685,7 +696,7 @@ export declare class TurbineClient {
|
|
|
685
696
|
*/
|
|
686
697
|
$transaction<R>(fn: (tx: TransactionClient) => Promise<R>, options?: TransactionOptions): Promise<R>;
|
|
687
698
|
/**
|
|
688
|
-
* Batch form
|
|
699
|
+
* Batch form, run a tuple of {@link DeferredQuery} objects (produced by the
|
|
689
700
|
* `build*()` methods, e.g. `db.users.buildFindMany(...)`) atomically inside a
|
|
690
701
|
* single `BEGIN…COMMIT` on one connection. Returns a positionally-typed tuple
|
|
691
702
|
* of each query's transformed result; any failure rolls the whole batch back.
|
|
@@ -693,8 +704,8 @@ export declare class TurbineClient {
|
|
|
693
704
|
* Unlike {@link pipeline}, this never uses the extended-query pipeline
|
|
694
705
|
* protocol. Statements run on the single transaction connection: strictly
|
|
695
706
|
* sequentially by default (safe on every driver, including HTTP/serverless
|
|
696
|
-
* pools), or
|
|
697
|
-
* {@link PgCompatPoolClient.supportsPipelining}
|
|
707
|
+
* pools), or, when the checked-out connection advertises
|
|
708
|
+
* {@link PgCompatPoolClient.supportsPipelining}, dispatched in one write
|
|
698
709
|
* burst with replies collected in order, saving a network round trip per
|
|
699
710
|
* statement. Either way the failure contract is identical: the first
|
|
700
711
|
* (lowest-index) failure aborts the batch and rolls everything back.
|
|
@@ -722,7 +733,7 @@ export declare class TurbineClient {
|
|
|
722
733
|
* {@link PgCompatPoolClient.supportsPipelining} (its `query()` accepts
|
|
723
734
|
* concurrent calls and completes them in FIFO submission order), all
|
|
724
735
|
* statements are dispatched in one write burst and the replies are
|
|
725
|
-
* collected in order
|
|
736
|
+
* collected in order, ~1 round trip plus server time. Only taken when
|
|
726
737
|
* the dialect's writes surface rows directly (`resultStrategy` !==
|
|
727
738
|
* 'reselect'): a reselect plan is itself a sequential write+read pair.
|
|
728
739
|
*
|
|
@@ -762,12 +773,12 @@ export declare class TurbineClient {
|
|
|
762
773
|
*
|
|
763
774
|
* The channel name CANNOT be a bound parameter (`LISTEN $1` is a syntax
|
|
764
775
|
* error), so it is validated against a strict identifier regex AND quoted via
|
|
765
|
-
* `quoteIdent` before interpolation
|
|
776
|
+
* `quoteIdent` before interpolation, it is the only identifier this method
|
|
766
777
|
* places into SQL text.
|
|
767
778
|
*
|
|
768
779
|
* **Serverless caveat:** LISTEN needs a persistent connection that can push
|
|
769
780
|
* async notifications. Stateless HTTP drivers (Neon HTTP, Vercel Postgres)
|
|
770
|
-
* cannot do this
|
|
781
|
+
* cannot do this, `$listen` throws a `ConnectionError` rather than hang.
|
|
771
782
|
* `$notify` works on every driver.
|
|
772
783
|
*
|
|
773
784
|
* @example
|
|
@@ -784,7 +795,7 @@ export declare class TurbineClient {
|
|
|
784
795
|
/**
|
|
785
796
|
* Send a Postgres NOTIFY on `channel` with an optional payload string.
|
|
786
797
|
*
|
|
787
|
-
* Issued as `SELECT pg_notify($1, $2)
|
|
798
|
+
* Issued as `SELECT pg_notify($1, $2)`, both the channel and payload are
|
|
788
799
|
* BOUND parameters (no quoting/injection concern). The channel is still
|
|
789
800
|
* validated against the identifier regex for parity with `$listen` and to
|
|
790
801
|
* catch typos loudly. Works on every driver, including serverless HTTP pools.
|
|
@@ -820,7 +831,7 @@ export declare class TurbineClient {
|
|
|
820
831
|
* Gracefully shut down the connection pool.
|
|
821
832
|
*
|
|
822
833
|
* If Turbine was given an external pool via `TurbineConfig.pool`, this
|
|
823
|
-
* method is a no-op
|
|
834
|
+
* method is a no-op, the caller is responsible for the pool's lifecycle.
|
|
824
835
|
*/
|
|
825
836
|
disconnect(): Promise<void>;
|
|
826
837
|
/** Alias for disconnect() */
|