bun-query-builder 0.2.43 → 0.2.45
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/dist/bin/cli.js +266 -102
- package/dist/browser.d.ts +11 -5
- package/dist/client.d.ts +30 -30
- package/dist/column-types.d.ts +26 -0
- package/dist/db.d.ts +36 -6
- package/dist/drivers/sqlite.d.ts +11 -6
- package/dist/dynamodb-client.d.ts +57 -18
- package/dist/dynamodb-single-table.d.ts +2 -2
- package/dist/dynamodb-tooling-adapter.d.ts +7 -6
- package/dist/meta.d.ts +1 -1
- package/dist/model.d.ts +4 -0
- package/dist/orm.d.ts +33 -13
- package/dist/schema.d.ts +35 -21
- package/dist/seeder.d.ts +11 -1
- package/dist/sql-fragments.d.ts +1 -1
- package/dist/src/browser.js +2 -2
- package/dist/src/index.js +266 -101
- package/dist/types.d.ts +34 -20
- package/package.json +1 -1
package/dist/browser.d.ts
CHANGED
|
@@ -282,13 +282,19 @@ export declare class BrowserQueryError extends Error {
|
|
|
282
282
|
export declare class BrowserQueryBuilder<T = any> {
|
|
283
283
|
constructor(table: string);
|
|
284
284
|
select(...columns: string[]): this;
|
|
285
|
-
where(column: string,
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
where(column: string, value: unknown): this;
|
|
286
|
+
where(column: string, operator: WhereOperator, value: unknown): this;
|
|
287
|
+
where(column: string, operatorOrValue: unknown, value?: unknown): this;
|
|
288
|
+
orWhere(column: string, value: unknown): this;
|
|
289
|
+
orWhere(column: string, operator: WhereOperator, value: unknown): this;
|
|
290
|
+
orWhere(column: string, operatorOrValue: unknown, value?: unknown): this;
|
|
291
|
+
andWhere(column: string, value: unknown): this;
|
|
292
|
+
andWhere(column: string, operator: WhereOperator, value: unknown): this;
|
|
293
|
+
andWhere(column: string, operatorOrValue: unknown, value?: unknown): this;
|
|
288
294
|
whereNull(column: string): this;
|
|
289
295
|
whereNotNull(column: string): this;
|
|
290
|
-
whereIn(column: string, values:
|
|
291
|
-
whereNotIn(column: string, values:
|
|
296
|
+
whereIn(column: string, values: readonly unknown[]): this;
|
|
297
|
+
whereNotIn(column: string, values: readonly unknown[]): this;
|
|
292
298
|
orderBy(column: string, direction?: 'asc' | 'desc'): this;
|
|
293
299
|
orderByDesc(column: string): this;
|
|
294
300
|
latest(column?: string): this;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from './config';
|
|
2
2
|
import { resetConnection } from './db';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AnyDatabaseSchema } from './schema';
|
|
4
4
|
import type { DriverConnection } from './db';
|
|
5
5
|
import type { QueryHooks, SupportedDialect } from './types';
|
|
6
6
|
import type { SchemaMeta } from './meta';
|
|
@@ -50,7 +50,7 @@ export declare function raw(strings: TemplateStringsArray | string, ...values: u
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function escapeStringLiteral(value: string, dialect?: SupportedDialect): string;
|
|
52
52
|
// eslint-disable-next-line pickier/no-unused-vars
|
|
53
|
-
export declare function createQueryBuilder<DB extends
|
|
53
|
+
export declare function createQueryBuilder<DB extends AnyDatabaseSchema>(state?: Partial<InternalState>): QueryBuilder<DB>;
|
|
54
54
|
/**
|
|
55
55
|
* # `clearQueryCache()`
|
|
56
56
|
*
|
|
@@ -80,7 +80,7 @@ declare interface RawExpression {
|
|
|
80
80
|
export declare interface WhereRaw {
|
|
81
81
|
raw: SqlFragment
|
|
82
82
|
}
|
|
83
|
-
export declare interface BaseSelectQueryBuilder<DB extends
|
|
83
|
+
export declare interface BaseSelectQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string, TSelected, TJoined extends string = TTable,> {
|
|
84
84
|
distinct: () => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
85
85
|
distinctOn: (...columns: (keyof DB[TTable]['columns'] & string | string)[]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
86
86
|
selectRaw: (fragment: SqlFragment) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
@@ -108,7 +108,7 @@ export declare interface BaseSelectQueryBuilder<DB extends DatabaseSchema<any>,
|
|
|
108
108
|
orWhereGroup: (callback: (builder: SelectQueryBuilder<DB, TTable, TSelected, TJoined>) => unknown) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
109
109
|
orWhereNull: (column: keyof DB[TTable]['columns'] & string) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
110
110
|
orWhereNotNull: (column: keyof DB[TTable]['columns'] & string) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
111
|
-
orWhereBetween:
|
|
111
|
+
orWhereBetween: <K extends keyof DB[TTable]['columns'] & string>(column: K, start: DB[TTable]['columns'][K], end: DB[TTable]['columns'][K]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
112
112
|
orWhereExists: (subquery: { toSQL: () => any }) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
113
113
|
orWhereRaw: (fragment: SqlFragment) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
114
114
|
whereAny: <K extends keyof DB[TTable]['columns'] & string>(columns: K[], op: WhereOperator, value: DB[TTable]['columns'][K]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
@@ -265,7 +265,7 @@ export declare interface BaseSelectQueryBuilder<DB extends DatabaseSchema<any>,
|
|
|
265
265
|
denseRank?: (alias?: string, partitionBy?: string | string[], orderBy?: [string, 'asc' | 'desc'][]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
266
266
|
rank?: (alias?: string, partitionBy?: string | string[], orderBy?: [string, 'asc' | 'desc'][]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
267
267
|
}
|
|
268
|
-
export declare interface InsertQueryBuilder<DB extends
|
|
268
|
+
export declare interface InsertQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string> {
|
|
269
269
|
values: (data: Partial<DB[TTable]['columns']> | Partial<DB[TTable]['columns']>[]) => InsertQueryBuilder<DB, TTable>
|
|
270
270
|
returning: <K extends keyof DB[TTable]['columns'] & string>(...cols: K[]) => SelectQueryBuilder<DB, TTable, Pick<DB[TTable]['columns'], K>>
|
|
271
271
|
toSQL: () => string
|
|
@@ -274,7 +274,7 @@ export declare interface InsertQueryBuilder<DB extends DatabaseSchema<any>, TTab
|
|
|
274
274
|
executeTakeFirst: () => Promise<DB[TTable]['columns'] | undefined>
|
|
275
275
|
executeTakeFirstOrThrow: () => Promise<DB[TTable]['columns']>
|
|
276
276
|
}
|
|
277
|
-
export declare interface UpdateQueryBuilder<DB extends
|
|
277
|
+
export declare interface UpdateQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string> {
|
|
278
278
|
set: (values: Partial<{ [K in keyof DB[TTable]['columns']]: DB[TTable]['columns'][K] | SqlFragment }>) => UpdateQueryBuilder<DB, TTable>
|
|
279
279
|
where: <K extends keyof DB[TTable]['columns'] & string>(
|
|
280
280
|
expr: WhereExpression<DB[TTable]['columns']> | K | SqlFragment,
|
|
@@ -290,7 +290,7 @@ export declare interface UpdateQueryBuilder<DB extends DatabaseSchema<any>, TTab
|
|
|
290
290
|
executeTakeFirst: () => Promise<{ numUpdatedRows?: number }>
|
|
291
291
|
executeTakeFirstOrThrow: () => Promise<{ numUpdatedRows: number }>
|
|
292
292
|
}
|
|
293
|
-
export declare interface DeleteQueryBuilder<DB extends
|
|
293
|
+
export declare interface DeleteQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string> {
|
|
294
294
|
where: <K extends keyof DB[TTable]['columns'] & string>(
|
|
295
295
|
expr: WhereExpression<DB[TTable]['columns']> | K,
|
|
296
296
|
op?: WhereOperator,
|
|
@@ -305,13 +305,13 @@ export declare interface DeleteQueryBuilder<DB extends DatabaseSchema<any>, TTab
|
|
|
305
305
|
executeTakeFirst: () => Promise<{ numDeletedRows?: number }>
|
|
306
306
|
executeTakeFirstOrThrow: () => Promise<{ numDeletedRows: number }>
|
|
307
307
|
}
|
|
308
|
-
export declare interface TableQueryBuilder<DB extends
|
|
308
|
+
export declare interface TableQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string> {
|
|
309
309
|
insert: (data: Partial<DB[TTable]['columns']> | Partial<DB[TTable]['columns']>[]) => InsertQueryBuilder<DB, TTable>
|
|
310
310
|
update: (values: Partial<DB[TTable]['columns']>) => UpdateQueryBuilder<DB, TTable>
|
|
311
311
|
delete: () => DeleteQueryBuilder<DB, TTable>
|
|
312
312
|
select: <K extends keyof DB[TTable]['columns'] & string>(...columns: K[]) => SelectQueryBuilder<DB, TTable, Pick<DB[TTable]['columns'], K>>
|
|
313
313
|
}
|
|
314
|
-
export declare interface QueryBuilder<DB extends
|
|
314
|
+
export declare interface QueryBuilder<DB extends AnyDatabaseSchema> {
|
|
315
315
|
select: {
|
|
316
316
|
<TTable extends keyof DB & string, K extends keyof DB[TTable]['columns'] & string>(
|
|
317
317
|
table: TTable,
|
|
@@ -434,25 +434,25 @@ export declare interface QueryBuilder<DB extends DatabaseSchema<any>> {
|
|
|
434
434
|
getRelationshipTarget?: (table: string, relationName: string) => string | null
|
|
435
435
|
}
|
|
436
436
|
declare interface InternalState {
|
|
437
|
-
sql:
|
|
437
|
+
sql: DriverConnection
|
|
438
438
|
meta?: SchemaMeta
|
|
439
|
-
schema?:
|
|
439
|
+
schema?: AnyDatabaseSchema
|
|
440
440
|
txDefaults?: TransactionOptions
|
|
441
441
|
hooks?: QueryHooks
|
|
442
442
|
inTransaction?: boolean
|
|
443
443
|
}
|
|
444
444
|
declare interface TxBackoff { baseMs?: number, maxMs?: number, factor?: number, jitter?: boolean }
|
|
445
|
-
declare interface TxLoggerEvent { type: 'start' | 'retry' | 'commit' | 'rollback' | 'error', attempt: number, error?:
|
|
445
|
+
declare interface TxLoggerEvent { type: 'start' | 'retry' | 'commit' | 'rollback' | 'error', attempt: number, error?: unknown, durationMs?: number }
|
|
446
446
|
export declare interface TransactionOptions {
|
|
447
447
|
retries?: number
|
|
448
448
|
isolation?: TransactionIsolation
|
|
449
|
-
onRetry?: (attempt: number, error:
|
|
449
|
+
onRetry?: (attempt: number, error: unknown) => void
|
|
450
450
|
afterCommit?: () => void
|
|
451
451
|
sqlStates?: string[]
|
|
452
452
|
backoff?: TxBackoff
|
|
453
453
|
logger?: (event: TxLoggerEvent) => void
|
|
454
454
|
readOnly?: boolean
|
|
455
|
-
onRollback?: (error:
|
|
455
|
+
onRollback?: (error: unknown) => void
|
|
456
456
|
afterRollback?: () => void
|
|
457
457
|
}
|
|
458
458
|
// Where condition helpers
|
|
@@ -497,10 +497,10 @@ export type SortDirection = 'asc' | 'desc';
|
|
|
497
497
|
*
|
|
498
498
|
* Helper type extracting a string union of column names for a given table.
|
|
499
499
|
*/
|
|
500
|
-
export type ColumnName<DB extends
|
|
500
|
+
export type ColumnName<DB extends AnyDatabaseSchema, TTable extends keyof DB & string> = keyof DB[TTable]['columns'] & string;
|
|
501
501
|
// Named row alias to improve IDE hover readability
|
|
502
|
-
export type SelectedRow<DB extends
|
|
503
|
-
declare type PrimaryKeyValue<DB extends
|
|
502
|
+
export type SelectedRow<DB extends AnyDatabaseSchema, _TTable extends keyof DB & string, TSelected,> = Readonly<TSelected>;
|
|
503
|
+
declare type PrimaryKeyValue<DB extends AnyDatabaseSchema, TTable extends keyof DB & string> = DB[TTable]['primaryKey'] extends keyof DB[TTable]['columns']
|
|
504
504
|
? DB[TTable]['columns'][DB[TTable]['primaryKey']]
|
|
505
505
|
: unknown;
|
|
506
506
|
declare type NumericColumnName<Columns> = {
|
|
@@ -508,7 +508,7 @@ declare type NumericColumnName<Columns> = {
|
|
|
508
508
|
? K
|
|
509
509
|
: Exclude<Columns[K], null | undefined> extends number ? K : never
|
|
510
510
|
}[keyof Columns & string];
|
|
511
|
-
declare type JoinColumn<DB extends
|
|
511
|
+
declare type JoinColumn<DB extends AnyDatabaseSchema, TTables extends string> = TTables extends any
|
|
512
512
|
? `${TTables}.${keyof DB[TTables]['columns'] & string}`
|
|
513
513
|
: never;
|
|
514
514
|
/**
|
|
@@ -521,20 +521,20 @@ declare type JoinColumn<DB extends DatabaseSchema<any>, TTables extends string>
|
|
|
521
521
|
* untyped schemas keep compiling. A table that declares ZERO relations
|
|
522
522
|
* yields `never` — every relation name is rejected.
|
|
523
523
|
*/
|
|
524
|
-
export type TableRelationName<DB extends
|
|
524
|
+
export type TableRelationName<DB extends AnyDatabaseSchema, TTable extends keyof DB & string> = DB[TTable] extends { relations?: infer R }
|
|
525
525
|
? unknown extends R ? string : keyof NonNullable<R> & string
|
|
526
526
|
: string;
|
|
527
|
-
declare type RelatedTableName<DB extends
|
|
527
|
+
declare type RelatedTableName<DB extends AnyDatabaseSchema, TTable extends keyof DB & string, TRelation extends TableRelationName<DB, TTable>,> = DB[TTable] extends { relations?: infer Relations }
|
|
528
528
|
? TRelation extends keyof NonNullable<Relations>
|
|
529
529
|
? Extract<NonNullable<Relations>[TRelation], keyof DB & string>
|
|
530
530
|
: keyof DB & string
|
|
531
531
|
: keyof DB & string;
|
|
532
|
-
declare type RelationQueryBuilder<DB extends
|
|
532
|
+
declare type RelationQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string, TRelation extends TableRelationName<DB, TTable>,> = SelectQueryBuilder<
|
|
533
533
|
DB,
|
|
534
534
|
RelatedTableName<DB, TTable, TRelation>,
|
|
535
535
|
DB[RelatedTableName<DB, TTable, TRelation>]['columns']
|
|
536
536
|
>;
|
|
537
|
-
declare type RelationConstraintRecord<DB extends
|
|
537
|
+
declare type RelationConstraintRecord<DB extends AnyDatabaseSchema, TTable extends keyof DB & string> = {
|
|
538
538
|
[R in TableRelationName<DB, TTable>]: Partial<Record<R, (qb: RelationQueryBuilder<DB, TTable, R>) => unknown>>
|
|
539
539
|
}[TableRelationName<DB, TTable>];
|
|
540
540
|
/**
|
|
@@ -546,7 +546,7 @@ declare type RelationConstraintRecord<DB extends DatabaseSchema<any>, TTable ext
|
|
|
546
546
|
* relations accepts nothing (the bare `Partial<Record<never, ...>>` would be
|
|
547
547
|
* `{}`, which strings are assignable to — hence the explicit never guard).
|
|
548
548
|
*/
|
|
549
|
-
export type WithRelationArg<DB extends
|
|
549
|
+
export type WithRelationArg<DB extends AnyDatabaseSchema, TTable extends keyof DB & string> = [TableRelationName<DB, TTable>] extends [never]
|
|
550
550
|
? never
|
|
551
551
|
:
|
|
552
552
|
| TableRelationName<DB, TTable>
|
|
@@ -559,7 +559,7 @@ declare type SnakeToPascal<S extends string> = S extends `${infer H}_${infer T}`
|
|
|
559
559
|
// Typed SQL builder (type-level only). We piggy-back on the runtime builder but
|
|
560
560
|
// thread a phantom TSql string through method signatures so hovers can show the
|
|
561
561
|
// composed SQL at compile-time for common operations.
|
|
562
|
-
declare type _TypedDynamicWhereMethods<DB extends
|
|
562
|
+
declare type _TypedDynamicWhereMethods<DB extends AnyDatabaseSchema, TTable extends keyof DB & string, TSelected, TJoined extends string, TSql extends string,> = {
|
|
563
563
|
[K in keyof DB[TTable]['columns'] & string as `where${SnakeToPascal<K>}`]: (
|
|
564
564
|
value: DB[TTable]['columns'][K],
|
|
565
565
|
) => TypedSelectQueryBuilder<DB, TTable, TSelected, TJoined, `${TSql} WHERE ${K} = ?`>
|
|
@@ -577,7 +577,7 @@ declare type _TypedDynamicWhereMethods<DB extends DatabaseSchema<any>, TTable ex
|
|
|
577
577
|
// untyped variant (returning a plain SelectQueryBuilder) would win overload
|
|
578
578
|
// resolution, silently downgrading `toSQL()` from the composed literal SQL
|
|
579
579
|
// type back to `string` after any dynamic-where call.
|
|
580
|
-
export type TypedSelectQueryBuilder<DB extends
|
|
580
|
+
export type TypedSelectQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string, TSelected, TJoined extends string = TTable, TSql extends string = `SELECT * FROM ${TTable}`,> = Omit<
|
|
581
581
|
BaseSelectQueryBuilder<DB, TTable, TSelected, TJoined>,
|
|
582
582
|
'toSQL' | 'where' | 'andWhere' | 'orWhere' | 'orderBy' | 'limit'
|
|
583
583
|
> & _TypedDynamicWhereMethods<DB, TTable, TSelected, TJoined, TSql>
|
|
@@ -616,16 +616,16 @@ export type TypedSelectQueryBuilder<DB extends DatabaseSchema<any>, TTable exten
|
|
|
616
616
|
) => TypedSelectQueryBuilder<DB, TTable, TSelected, TJoined, `${TSql} ORDER BY ${C} ${D}`>
|
|
617
617
|
limit: <N extends number>(n: N) => TypedSelectQueryBuilder<DB, TTable, TSelected, TJoined, `${TSql} LIMIT ${N}`>
|
|
618
618
|
}
|
|
619
|
-
declare type DynamicWhereMethods<DB extends
|
|
619
|
+
declare type DynamicWhereMethods<DB extends AnyDatabaseSchema, TTable extends keyof DB & string, TSelected, TJoined extends string = TTable,> = {
|
|
620
620
|
[K in keyof DB[TTable]['columns'] & string as `where${SnakeToPascal<K>}`]: (value: DB[TTable]['columns'][K]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
621
621
|
} & {
|
|
622
622
|
[K in keyof DB[TTable]['columns'] & string as `orWhere${SnakeToPascal<K>}`]: (value: DB[TTable]['columns'][K]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
623
623
|
} & {
|
|
624
624
|
[K in keyof DB[TTable]['columns'] & string as `andWhere${SnakeToPascal<K>}`]: (value: DB[TTable]['columns'][K]) => SelectQueryBuilder<DB, TTable, TSelected, TJoined>
|
|
625
625
|
}
|
|
626
|
-
export type SelectQueryBuilder<DB extends
|
|
626
|
+
export type SelectQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string, TSelected, TJoined extends string = TTable,> = BaseSelectQueryBuilder<DB, TTable, TSelected, TJoined> & DynamicWhereMethods<DB, TTable, TSelected, TJoined>;
|
|
627
627
|
// Typed INSERT builder to expose a structured SQL literal in hovers
|
|
628
|
-
export type TypedInsertQueryBuilder<DB extends
|
|
628
|
+
export type TypedInsertQueryBuilder<DB extends AnyDatabaseSchema, TTable extends keyof DB & string, TSql extends string = `INSERT INTO ${TTable}`,> = Omit<InsertQueryBuilder<DB, TTable>, 'toSQL' | 'values' | 'returning'> & {
|
|
629
629
|
toSQL: () => TSql
|
|
630
630
|
values: (
|
|
631
631
|
data: Partial<DB[TTable]['columns']> | Partial<DB[TTable]['columns']>[],
|
|
@@ -642,8 +642,8 @@ export type TypedInsertQueryBuilder<DB extends DatabaseSchema<any>, TTable exten
|
|
|
642
642
|
}
|
|
643
643
|
declare type TransactionIsolation = 'read committed' | 'repeatable read' | 'serializable';
|
|
644
644
|
declare class QueryCache {
|
|
645
|
-
get(key: string):
|
|
646
|
-
set(key: string, data:
|
|
645
|
+
get<T = unknown>(key: string): T | null;
|
|
646
|
+
set(key: string, data: unknown, ttlMs: number): void;
|
|
647
647
|
clear(): void;
|
|
648
648
|
setMaxSize(size: number): void;
|
|
649
649
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { NormalizedColumnType } from './migrations';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a canonical type stores a number.
|
|
4
|
+
*
|
|
5
|
+
* Used to decide when the `*_id` naming heuristic may coerce a column to
|
|
6
|
+
* INTEGER. Declared text types must never be coerced by a name heuristic —
|
|
7
|
+
* external ids are frequently strings (tickers, wallet addresses, hashes).
|
|
8
|
+
*/
|
|
9
|
+
export declare function isNumericPlanType(type: string | undefined): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Map a declared attribute type onto the canonical set.
|
|
12
|
+
*
|
|
13
|
+
* Accepts the spellings the model layer and the validation-rule reader already
|
|
14
|
+
* accept, so `type: 'int'`, `'bool'` and `'timestamp'` land where their long
|
|
15
|
+
* forms do. Returns `undefined` for anything unrecognised, which callers treat
|
|
16
|
+
* as "no opinion" rather than guessing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function normalizeAttributeType(raw: unknown): NormalizedColumnType | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The SQLite storage class for a canonical type.
|
|
21
|
+
*
|
|
22
|
+
* `enum` is TEXT here; the migration driver additionally emits a CHECK
|
|
23
|
+
* constraint, which needs the column name and a quoter and so stays with the
|
|
24
|
+
* driver.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sqliteAffinityFor(type: NormalizedColumnType | undefined): 'TEXT' | 'INTEGER' | 'REAL';
|
package/dist/db.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { Database } from 'bun:sqlite';
|
|
2
2
|
import { SQL } from 'bun';
|
|
3
|
+
import type { SQLQueryBindings } from 'bun:sqlite';
|
|
3
4
|
import type { DatabaseConfig, PoolConfig, SupportedDialect } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* The one place user values become driver bindings.
|
|
7
|
+
*
|
|
8
|
+
* Everything a caller interpolates arrives as `unknown` - that is honest, we
|
|
9
|
+
* do not know what it is. bun:sqlite accepts a narrower set. The conversion is
|
|
10
|
+
* unchecked because the driver itself is the validator: it throws a clear
|
|
11
|
+
* "can't bind" for anything it cannot take, and a check here would only
|
|
12
|
+
* duplicate that rule and drift from it. Kept as one named function so the
|
|
13
|
+
* boundary is visible, rather than an `any` at each of the six call sites.
|
|
14
|
+
*/
|
|
15
|
+
export declare function toBindings(params: readonly unknown[]): SQLQueryBindings[];
|
|
16
|
+
/** A template value seen as a possible fragment; null when it is a plain bind param. */
|
|
17
|
+
export declare function asEmbeddedValue(value: unknown): EmbeddedValue | null;
|
|
4
18
|
/**
|
|
5
19
|
* SQLite wrapper that provides a SQL-like tagged template literal interface
|
|
6
20
|
* using bun:sqlite's Database class for better compiled binary support.
|
|
@@ -29,7 +43,7 @@ import type { DatabaseConfig, PoolConfig, SupportedDialect } from './types';
|
|
|
29
43
|
* numbered placeholders is returned untouched, so `?` queries and Bun's own
|
|
30
44
|
* tagged-template output are unaffected.
|
|
31
45
|
*/
|
|
32
|
-
export declare function bindNumberedPlaceholders(sql: string, params:
|
|
46
|
+
export declare function bindNumberedPlaceholders<T>(sql: string, params: T[]): { sql: string, params: T[] };
|
|
33
47
|
export declare function splitSqlStatements(sql: string): string[];
|
|
34
48
|
/**
|
|
35
49
|
* Creates a database connection string based on the configured dialect and database settings.
|
|
@@ -108,6 +122,22 @@ export declare const bunSql: SQL;
|
|
|
108
122
|
* Both Bun's native `SQL` query and our `createSQLiteSQL` wrapper satisfy this.
|
|
109
123
|
* See stacksjs/bun-query-builder#1044.
|
|
110
124
|
*/
|
|
125
|
+
/**
|
|
126
|
+
* What a value interpolated into a tagged template can turn out to be.
|
|
127
|
+
*
|
|
128
|
+
* Three things arrive here: a plain bind param, a nested query (carries `sql`
|
|
129
|
+
* plus a `values` ARRAY), and a raw-SQL marker (carries `__raw`/`raw` and no
|
|
130
|
+
* `values`). Naming the shape is what lets the branches below read properties
|
|
131
|
+
* without an `any` - and the order of those branches is load-bearing, see
|
|
132
|
+
* stacksjs/bun-query-builder#1084.
|
|
133
|
+
*/
|
|
134
|
+
export declare interface EmbeddedValue {
|
|
135
|
+
sql?: unknown
|
|
136
|
+
values?: unknown
|
|
137
|
+
__raw?: unknown
|
|
138
|
+
raw?: unknown
|
|
139
|
+
value?: unknown
|
|
140
|
+
}
|
|
111
141
|
export declare interface DriverQuery {
|
|
112
142
|
execute: () => Promise<any>
|
|
113
143
|
values?: () => any
|
|
@@ -124,10 +154,10 @@ export declare interface DriverQuery {
|
|
|
124
154
|
* casts be dropped. See stacksjs/bun-query-builder#1044.
|
|
125
155
|
*/
|
|
126
156
|
export declare interface DriverConnection {
|
|
127
|
-
(strings: TemplateStringsArray, ...values:
|
|
157
|
+
(strings: TemplateStringsArray, ...values: unknown[]): DriverQuery
|
|
128
158
|
(value: any): any
|
|
129
|
-
unsafe: (sql: string, values?:
|
|
130
|
-
query?: (sql: string, params?:
|
|
159
|
+
unsafe: (sql: string, values?: unknown[]) => AwaitableDriverQuery
|
|
160
|
+
query?: (sql: string, params?: unknown[]) => any
|
|
131
161
|
close?: () => Promise<void> | void
|
|
132
162
|
_prepareStatement?: (sql: string) => any
|
|
133
163
|
[key: string]: any
|
|
@@ -136,8 +166,8 @@ export declare interface DriverConnection {
|
|
|
136
166
|
export type AwaitableDriverQuery = DriverQuery & PromiseLike<any>;
|
|
137
167
|
declare class SQLiteWrapper {
|
|
138
168
|
constructor(filename: string);
|
|
139
|
-
query(sql: string, params?:
|
|
140
|
-
run(sql: string, params?:
|
|
169
|
+
query(sql: string, params?: SQLQueryBindings[]): any[];
|
|
170
|
+
run(sql: string, params?: SQLQueryBindings[]): any;
|
|
141
171
|
close(): void;
|
|
142
172
|
get database(): Database;
|
|
143
173
|
}
|
package/dist/drivers/sqlite.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
+
import { isNumericPlanType } from '../column-types';
|
|
1
2
|
import type { ColumnPlan, IndexPlan, RebuildTableSpec, TablePlan } from '../migrations';
|
|
2
3
|
import type { DateBucketGrain } from './postgres';
|
|
3
|
-
/**
|
|
4
|
-
* Whether a plan type belongs to the numeric family. Used by the `_id`
|
|
5
|
-
* safety net (numeric ids must store as INTEGER on SQLite) — non-numeric
|
|
6
|
-
* declared types must never be coerced by the name heuristic.
|
|
7
|
-
*/
|
|
8
|
-
export declare function isNumericPlanType(type: string | undefined): boolean;
|
|
9
4
|
export declare interface DialectDriver {
|
|
10
5
|
createEnumType: (enumTypeName: string, values: string[]) => string
|
|
11
6
|
createTable: (table: TablePlan) => string
|
|
@@ -45,3 +40,13 @@ export declare class SQLiteDriver implements DialectDriver {
|
|
|
45
40
|
dateBucket(column: string, grain: DateBucketGrain, offsetHours?: number): string;
|
|
46
41
|
booleanLiteral(value: boolean): string;
|
|
47
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether a plan type belongs to the numeric family. Used by the `_id`
|
|
45
|
+
* safety net (numeric ids must store as INTEGER on SQLite) — non-numeric
|
|
46
|
+
* declared types must never be coerced by the name heuristic.
|
|
47
|
+
*
|
|
48
|
+
* Defined in column-types.ts now, so the ORM's create-table path applies the
|
|
49
|
+
* same rule from the same source. Re-exported because this is where callers
|
|
50
|
+
* already import it from.
|
|
51
|
+
*/
|
|
52
|
+
export { isNumericPlanType };
|
|
@@ -11,12 +11,31 @@ export declare function createDynamoDBItemBuilder<T = any>(options: DynamoDBQuer
|
|
|
11
11
|
* Create a DynamoDB client with fluent query builder methods
|
|
12
12
|
*/
|
|
13
13
|
export declare function createDynamoDBClient(options: DynamoDBQueryBuilderOptions): DynamoDBClientMethods;
|
|
14
|
+
/**
|
|
15
|
+
* The AWS SDK client, described by the one method this package uses.
|
|
16
|
+
*
|
|
17
|
+
* `@aws-sdk/client-dynamodb` is not a dependency (callers bring their own),
|
|
18
|
+
* so the shape is structural: anything with a `send` satisfies it, including
|
|
19
|
+
* the real `DynamoDBClient` and a test double.
|
|
20
|
+
*/
|
|
21
|
+
export declare interface DynamoDBClientLike {
|
|
22
|
+
send: (command: unknown) => Promise<unknown>
|
|
23
|
+
[key: string]: unknown
|
|
24
|
+
}
|
|
25
|
+
/** What DynamoDB reports about the capacity a call consumed. */
|
|
26
|
+
export declare interface DynamoDBConsumedCapacity {
|
|
27
|
+
TableName?: string
|
|
28
|
+
CapacityUnits?: number
|
|
29
|
+
ReadCapacityUnits?: number
|
|
30
|
+
WriteCapacityUnits?: number
|
|
31
|
+
[key: string]: unknown
|
|
32
|
+
}
|
|
14
33
|
/**
|
|
15
34
|
* DynamoDB Query Builder Options
|
|
16
35
|
*/
|
|
17
36
|
export declare interface DynamoDBQueryBuilderOptions {
|
|
18
37
|
config: DynamoDBConfig
|
|
19
|
-
client?:
|
|
38
|
+
client?: DynamoDBClientLike
|
|
20
39
|
}
|
|
21
40
|
/**
|
|
22
41
|
* Result type for DynamoDB operations
|
|
@@ -27,7 +46,7 @@ export declare interface DynamoDBResult<T = any> {
|
|
|
27
46
|
count?: number
|
|
28
47
|
scannedCount?: number
|
|
29
48
|
lastEvaluatedKey?: Record<string, any>
|
|
30
|
-
consumedCapacity?:
|
|
49
|
+
consumedCapacity?: DynamoDBConsumedCapacity
|
|
31
50
|
}
|
|
32
51
|
/**
|
|
33
52
|
* DynamoDB Client Factory
|
|
@@ -41,6 +60,26 @@ export declare interface DynamoDBClientMethods {
|
|
|
41
60
|
registerEntity: (mapping: SingleTableEntityMapping) => void
|
|
42
61
|
buildKey: (entityType: string, values: Record<string, any>) => { pk: string, sk: string }
|
|
43
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* A value DynamoDB can store or compare against.
|
|
65
|
+
*
|
|
66
|
+
* DynamoDB's type system is small and closed - scalars, binary, lists and
|
|
67
|
+
* maps - so the attribute surface below says that rather than `any`. A value
|
|
68
|
+
* outside this set could never have round-tripped through the wire format.
|
|
69
|
+
*/
|
|
70
|
+
export type DynamoDBValue = | string
|
|
71
|
+
| number
|
|
72
|
+
| boolean
|
|
73
|
+
| null
|
|
74
|
+
| Uint8Array
|
|
75
|
+
| DynamoDBValue[]
|
|
76
|
+
| { [key: string]: DynamoDBValue }
|
|
77
|
+
/** Every operator a DynamoDB filter expression accepts. */
|
|
78
|
+
export type DynamoDBFilterOperator = | DynamoDBComparisonOperator
|
|
79
|
+
| 'contains'
|
|
80
|
+
| 'attribute_exists'
|
|
81
|
+
| 'attribute_not_exists'
|
|
82
|
+
| 'IN';
|
|
44
83
|
/**
|
|
45
84
|
* DynamoDB Query Builder
|
|
46
85
|
*
|
|
@@ -51,23 +90,23 @@ export declare class DynamoDBQueryBuilder<T = any> {
|
|
|
51
90
|
table(tableName: string): this;
|
|
52
91
|
index(indexName: string): this;
|
|
53
92
|
entity(entityType: string): this;
|
|
54
|
-
whereKey(attribute: string, operator: DynamoDBComparisonOperator, value:
|
|
55
|
-
wherePartitionKey(attribute: string, value:
|
|
56
|
-
whereSortKey(attribute: string, value:
|
|
93
|
+
whereKey(attribute: string, operator: DynamoDBComparisonOperator, value: DynamoDBValue): this;
|
|
94
|
+
wherePartitionKey(attribute: string, value: DynamoDBValue): this;
|
|
95
|
+
whereSortKey(attribute: string, value: DynamoDBValue): this;
|
|
57
96
|
whereSortKeyBeginsWith(attribute: string, prefix: string): this;
|
|
58
|
-
whereSortKeyBetween(attribute: string, start:
|
|
59
|
-
where(attribute: string, operator:
|
|
60
|
-
whereEquals(attribute: string, value:
|
|
61
|
-
whereLessThan(attribute: string, value:
|
|
62
|
-
whereLessThanOrEqual(attribute: string, value:
|
|
63
|
-
whereGreaterThan(attribute: string, value:
|
|
64
|
-
whereGreaterThanOrEqual(attribute: string, value:
|
|
65
|
-
whereBetween(attribute: string, start:
|
|
97
|
+
whereSortKeyBetween(attribute: string, start: DynamoDBValue, end: DynamoDBValue): this;
|
|
98
|
+
where(attribute: string, operator: DynamoDBFilterOperator, value?: DynamoDBValue): this;
|
|
99
|
+
whereEquals(attribute: string, value: DynamoDBValue): this;
|
|
100
|
+
whereLessThan(attribute: string, value: DynamoDBValue): this;
|
|
101
|
+
whereLessThanOrEqual(attribute: string, value: DynamoDBValue): this;
|
|
102
|
+
whereGreaterThan(attribute: string, value: DynamoDBValue): this;
|
|
103
|
+
whereGreaterThanOrEqual(attribute: string, value: DynamoDBValue): this;
|
|
104
|
+
whereBetween(attribute: string, start: DynamoDBValue, end: DynamoDBValue): this;
|
|
66
105
|
whereBeginsWith(attribute: string, prefix: string): this;
|
|
67
|
-
whereContains(attribute: string, value:
|
|
106
|
+
whereContains(attribute: string, value: DynamoDBValue): this;
|
|
68
107
|
whereExists(attribute: string): this;
|
|
69
108
|
whereNotExists(attribute: string): this;
|
|
70
|
-
whereIn(attribute: string, values:
|
|
109
|
+
whereIn(attribute: string, values: DynamoDBValue[]): this;
|
|
71
110
|
select(...attributes: string[]): this;
|
|
72
111
|
limit(count: number): this;
|
|
73
112
|
ascending(): this;
|
|
@@ -93,11 +132,11 @@ export declare class DynamoDBItemBuilder<T = any> {
|
|
|
93
132
|
table(tableName: string): this;
|
|
94
133
|
key(key: Record<string, any>): this;
|
|
95
134
|
item(data: Record<string, any>): this;
|
|
96
|
-
set(attribute: string, value:
|
|
135
|
+
set(attribute: string, value: DynamoDBValue): this;
|
|
97
136
|
setMany(values: Record<string, any>): this;
|
|
98
137
|
remove(attribute: string): this;
|
|
99
|
-
add(attribute: string, value:
|
|
100
|
-
deleteFromSet(attribute: string, values:
|
|
138
|
+
add(attribute: string, value: DynamoDBValue): this;
|
|
139
|
+
deleteFromSet(attribute: string, values: DynamoDBValue): this;
|
|
101
140
|
condition(expression: string): this;
|
|
102
141
|
ifNotExists(attribute?: string): this;
|
|
103
142
|
ifExists(attribute?: string): this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DynamoDBQueryBuilderOptions } from './dynamodb-client';
|
|
1
|
+
import type { DynamoDBFilterOperator, DynamoDBQueryBuilderOptions, DynamoDBValue } from './dynamodb-client';
|
|
2
2
|
import type { DynamoDBTableDefinition } from './drivers/dynamodb';
|
|
3
3
|
/**
|
|
4
4
|
* Create a single table manager
|
|
@@ -135,7 +135,7 @@ export declare class SingleTableQueryBuilder<T> {
|
|
|
135
135
|
whereSortKey(skData: Record<string, any>): this;
|
|
136
136
|
whereSortKeyBeginsWith(prefix: string): this;
|
|
137
137
|
useIndex(indexName: string, pkData: Record<string, any>): this;
|
|
138
|
-
where(attribute: string, operator:
|
|
138
|
+
where(attribute: string, operator: DynamoDBFilterOperator, value?: DynamoDBValue): this;
|
|
139
139
|
select(...attributes: string[]): this;
|
|
140
140
|
limit(count: number): this;
|
|
141
141
|
descending(): this;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DynamoDBItemBuilder, DynamoDBQueryBuilder } from './dynamodb-client';
|
|
2
2
|
import { SingleTableManager, SingleTableRepository } from './dynamodb-single-table';
|
|
3
|
-
import type {
|
|
3
|
+
import type { DynamoDBClientLike } from './dynamodb-client';
|
|
4
|
+
import type { DynamoDBDriver, DynamoDBTableDefinition } from './drivers/dynamodb';
|
|
4
5
|
/**
|
|
5
6
|
* Resolve key pattern placeholders with actual values
|
|
6
7
|
*/
|
|
@@ -8,7 +9,7 @@ export declare function resolveKeyPattern(keyPatterns: KeyPatterns, data: Record
|
|
|
8
9
|
/**
|
|
9
10
|
* Parse models from configuration (stub implementation)
|
|
10
11
|
*/
|
|
11
|
-
export declare function parseStacksModels(_config:
|
|
12
|
+
export declare function parseStacksModels(_config: unknown): Promise<{ models: Map<string, ParsedModel> }>;
|
|
12
13
|
/**
|
|
13
14
|
* Convert model instance to DynamoDB item format (stub)
|
|
14
15
|
*/
|
|
@@ -63,7 +64,7 @@ export declare interface ParsedAttribute {
|
|
|
63
64
|
nullable: boolean
|
|
64
65
|
unique: boolean
|
|
65
66
|
hidden: boolean
|
|
66
|
-
defaultValue?:
|
|
67
|
+
defaultValue?: unknown
|
|
67
68
|
cast?: string
|
|
68
69
|
dynamoDbType: 'S' | 'N' | 'B' | 'BOOL' | 'NULL' | 'M' | 'L' | 'SS' | 'NS' | 'BS'
|
|
69
70
|
}
|
|
@@ -127,7 +128,7 @@ export declare interface StacksModel {
|
|
|
127
128
|
nullable?: boolean
|
|
128
129
|
unique?: boolean
|
|
129
130
|
hidden?: boolean
|
|
130
|
-
default?:
|
|
131
|
+
default?: unknown
|
|
131
132
|
cast?: string
|
|
132
133
|
validation?: { rule?: string }
|
|
133
134
|
}>
|
|
@@ -177,7 +178,7 @@ export declare interface DynamoDBToolingConfig {
|
|
|
177
178
|
*/
|
|
178
179
|
export declare class DynamoDBToolingAdapter {
|
|
179
180
|
constructor(config: DynamoDBToolingConfig);
|
|
180
|
-
setClient(client:
|
|
181
|
+
setClient(client: DynamoDBClientLike): this;
|
|
181
182
|
discoverModels(): Promise<ParsedModel[]>;
|
|
182
183
|
registerModel(model: StacksModel): ParsedModel;
|
|
183
184
|
registerParsedModel(parsed: ParsedModel): ParsedModel;
|
|
@@ -192,6 +193,6 @@ export declare class DynamoDBToolingAdapter {
|
|
|
192
193
|
parseItem<T = any>(item: Record<string, any>): { type: string, data: T } | undefined;
|
|
193
194
|
getDriver(): DynamoDBDriver;
|
|
194
195
|
getSingleTableManager(): SingleTableManager;
|
|
195
|
-
generateTableDefinition():
|
|
196
|
+
generateTableDefinition(): DynamoDBTableDefinition;
|
|
196
197
|
generateAccessPatterns(modelName: string): AccessPattern[];
|
|
197
198
|
}
|
package/dist/meta.d.ts
CHANGED
|
@@ -17,6 +17,6 @@ export declare interface SchemaMeta {
|
|
|
17
17
|
morphToMany?: Record<string, string>
|
|
18
18
|
morphedByMany?: Record<string, string>
|
|
19
19
|
}>
|
|
20
|
-
scopes?: Record<string, Record<string, (qb: any, value?:
|
|
20
|
+
scopes?: Record<string, Record<string, (qb: any, value?: unknown) => unknown>>
|
|
21
21
|
models?: ModelRecord
|
|
22
22
|
}
|
package/dist/model.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export declare function getModelRegistry(): Record<string, ReturnType<typeof cre
|
|
|
51
51
|
export declare function hasModel(name: string): boolean;
|
|
52
52
|
/**
|
|
53
53
|
* Clear all registered models. Primarily useful for testing.
|
|
54
|
+
*
|
|
55
|
+
* Also drops the models `createModel` registered internally, and the memoized
|
|
56
|
+
* relation resolutions derived from them. Leaving either behind lets a stale
|
|
57
|
+
* resolution from one test file decide a relation's table in the next.
|
|
54
58
|
*/
|
|
55
59
|
export declare function clearModelRegistry(): void;
|
|
56
60
|
/**
|
package/dist/orm.d.ts
CHANGED
|
@@ -14,18 +14,11 @@ export type {
|
|
|
14
14
|
FillableKeys,
|
|
15
15
|
HiddenKeys,
|
|
16
16
|
};
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* Verified against live Postgres (Bun 1.3): a non-RETURNING `UPDATE`/`DELETE`
|
|
21
|
-
* returns an empty array carrying `{ count: <affected>, affectedRows: null,
|
|
22
|
-
* command: 'UPDATE' }`. So `count` must be checked BEFORE the `Array.length`
|
|
23
|
-
* fallback (which would be 0) — see stacksjs/bun-query-builder#1032. MySQL
|
|
24
|
-
* surfaces `affectedRows` instead.
|
|
25
|
-
*/
|
|
26
|
-
export declare function extractChanges(res: any): number;
|
|
17
|
+
/** Drops the `createModel` models. Paired with `clearModelRegistry()`. */
|
|
18
|
+
export declare function clearLocalModels(): void;
|
|
19
|
+
export declare function extractChanges(res: WriteResultLike | null | undefined): number;
|
|
27
20
|
/** Extract a generated primary key from a Bun SQL driver result. */
|
|
28
|
-
export declare function extractInsertId(res:
|
|
21
|
+
export declare function extractInsertId(res: WriteResultLike | null | undefined): number | bigint | null;
|
|
29
22
|
export declare function configureOrm(options: { database?: string | Database; verbose?: boolean }): void;
|
|
30
23
|
/**
|
|
31
24
|
* Return the underlying `bun:sqlite` Database backing the model layer.
|
|
@@ -138,8 +131,8 @@ export declare interface ModelDefinition {
|
|
|
138
131
|
readonly attributes: {
|
|
139
132
|
readonly [key: string]: TypedAttribute<unknown>
|
|
140
133
|
}
|
|
141
|
-
readonly get?: Record<string, (attributes:
|
|
142
|
-
readonly set?: Record<string, (attributes:
|
|
134
|
+
readonly get?: Record<string, (attributes: Record<string, unknown>) => unknown>
|
|
135
|
+
readonly set?: Record<string, (attributes: Record<string, unknown>) => unknown>
|
|
143
136
|
readonly scopes?: Record<string, (value: unknown) => unknown>
|
|
144
137
|
readonly indexes?: readonly object[]
|
|
145
138
|
readonly dashboard?: { readonly enabled?: boolean; readonly highlight?: boolean | number }
|
|
@@ -160,6 +153,33 @@ declare interface OrmExecutor {
|
|
|
160
153
|
insert: (sql: string, params: unknown[], primaryKey: string) => Promise<RunResult>
|
|
161
154
|
readonly sqliteDb?: Database
|
|
162
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Extract an affected-row count from a Bun SQL driver result.
|
|
158
|
+
*
|
|
159
|
+
* Verified against live Postgres (Bun 1.3): a non-RETURNING `UPDATE`/`DELETE`
|
|
160
|
+
* returns an empty array carrying `{ count: <affected>, affectedRows: null,
|
|
161
|
+
* command: 'UPDATE' }`. So `count` must be checked BEFORE the `Array.length`
|
|
162
|
+
* fallback (which would be 0) — see stacksjs/bun-query-builder#1032. MySQL
|
|
163
|
+
* surfaces `affectedRows` instead.
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* What a driver hands back after a write.
|
|
167
|
+
*
|
|
168
|
+
* Each one reports the affected count under its own name - and Postgres
|
|
169
|
+
* returns an empty array carrying `count`, so the shape is genuinely a union
|
|
170
|
+
* rather than one thing. Naming the fields beats `any`: a caller reading this
|
|
171
|
+
* type learns which drivers report what.
|
|
172
|
+
*/
|
|
173
|
+
export declare interface WriteResultLike {
|
|
174
|
+
affectedRows?: number
|
|
175
|
+
count?: number
|
|
176
|
+
changes?: number
|
|
177
|
+
lastInsertRowid?: number | bigint
|
|
178
|
+
insertId?: number | bigint
|
|
179
|
+
command?: string
|
|
180
|
+
rows?: unknown[]
|
|
181
|
+
[key: string]: unknown
|
|
182
|
+
}
|
|
163
183
|
/**
|
|
164
184
|
* Resolve a relation from its name and the parent model's definition.
|
|
165
185
|
* Uses the model registry to find the related model's definition.
|