@orkestrel/database 0.0.13 → 0.0.15
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 +10 -6
- package/dist/src/browser/index.d.ts +54 -51
- package/dist/src/browser/index.js +37 -31
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +170 -117
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +274 -61
- package/dist/src/core/index.d.ts +274 -61
- package/dist/src/core/index.js +171 -118
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +78 -58
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +93 -76
- package/dist/src/server/index.d.ts +93 -76
- package/dist/src/server/index.js +79 -59
- package/dist/src/server/index.js.map +1 -1
- package/package.json +17 -18
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import { AggregateOperation } from '@orkestrel/database';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { SQLiteRow } from '@orkestrel/sqlite';
|
|
20
|
-
import { SQLiteValue } from '@orkestrel/sqlite';
|
|
21
|
-
import { StorageInterface } from '@orkestrel/database';
|
|
22
|
-
import { TableSchema } from '@orkestrel/database';
|
|
23
|
-
import { TableSchema as TableSchema_2 } from '@orkestrel/database';
|
|
1
|
+
import type { AggregateOperation } from '@orkestrel/database';
|
|
2
|
+
import type { ColumnSchema } from '@orkestrel/database';
|
|
3
|
+
import type { ColumnStorage } from '@orkestrel/database';
|
|
4
|
+
import type { Condition } from '@orkestrel/database';
|
|
5
|
+
import type { DriverInterface } from '@orkestrel/database';
|
|
6
|
+
import type { DriverMetadata } from '@orkestrel/database';
|
|
7
|
+
import type { FieldPath } from '@orkestrel/contract';
|
|
8
|
+
import type { Key } from '@orkestrel/database';
|
|
9
|
+
import type { MigrationInput } from '@orkestrel/database';
|
|
10
|
+
import type { MigrationStep } from '@orkestrel/database';
|
|
11
|
+
import type { OperationOptions } from '@orkestrel/database';
|
|
12
|
+
import type { Order } from '@orkestrel/database';
|
|
13
|
+
import type { QueryInput } from '@orkestrel/database';
|
|
14
|
+
import type { Row } from '@orkestrel/database';
|
|
15
|
+
import type { SQLiteRow } from '@orkestrel/sqlite';
|
|
16
|
+
import type { SQLiteValue } from '@orkestrel/sqlite';
|
|
17
|
+
import type { StorageInterface } from '@orkestrel/database';
|
|
18
|
+
import type { TableSchema } from '@orkestrel/database';
|
|
24
19
|
|
|
25
20
|
/**
|
|
26
21
|
* Compiles an {@link AggregateOperation} over a {@link FieldPath}.
|
|
@@ -45,20 +40,20 @@ export declare function compileColumnSQL(storage: ColumnStorage): string;
|
|
|
45
40
|
*
|
|
46
41
|
* @remarks
|
|
47
42
|
* Every operand is run through `encodeValue`, so a bound value matches the SQL
|
|
48
|
-
* the column side compiles to. A flat column encodes operands with its
|
|
43
|
+
* the column side compiles to. A flat column encodes operands with its declared
|
|
49
44
|
* schema type (a flat `json` column → `JSON.stringify`); a nested `FieldPath`
|
|
50
|
-
* encodes each operand as the
|
|
45
|
+
* encodes each operand as the native scalar `json_extract` returns, derived from
|
|
51
46
|
* the operand's runtime type (per-operand, since `between` / `any` / `none` can
|
|
52
47
|
* mix types). `any` / `none` collapse an empty list to a constant (`0` matches
|
|
53
48
|
* nothing, `1` matches all) with no parameters.
|
|
54
49
|
*
|
|
55
|
-
* The core engine's total order ranks `undefined` (rank 0)
|
|
56
|
-
* (rank 1) (see `compareValues`), so a
|
|
50
|
+
* The core engine's total order ranks `undefined` (rank 0) below `null`
|
|
51
|
+
* (rank 1) (see `compareValues`), so a missing/`NULL` column matches
|
|
57
52
|
* `below` / `to` / a scalar `not` / `none` — the opposite of raw SQL, where a
|
|
58
53
|
* comparison against `NULL` is `NULL` (excluded). This fragment replicates the
|
|
59
54
|
* engine exactly. Truth table (`value` = the engine's decoded field read; a
|
|
60
|
-
*
|
|
61
|
-
* flat `value` is
|
|
55
|
+
* flat column's stored `NULL` decodes to `undefined` per `decodeRow`, so a
|
|
56
|
+
* flat `value` is never a present `null` — only a nested path can be
|
|
62
57
|
* present-but-`null`):
|
|
63
58
|
*
|
|
64
59
|
* ```text
|
|
@@ -84,15 +79,15 @@ export declare function compileColumnSQL(storage: ColumnStorage): string;
|
|
|
84
79
|
* refines every optional or nullable scalar comparison through the core engine.
|
|
85
80
|
* This compiler still emits a total SQL fragment for direct consumers.
|
|
86
81
|
*
|
|
87
|
-
* A
|
|
88
|
-
* `json_extract` reads back as SQL `NULL` — indistinguishable from an
|
|
82
|
+
* A nested path can be present-but-`null` (a stored JSON `null`), which
|
|
83
|
+
* `json_extract` reads back as SQL `NULL` — indistinguishable from an absent
|
|
89
84
|
* path. `json_type(col, path)` disambiguates them (`'null'` for present-null,
|
|
90
85
|
* SQL `NULL` for absent), so nested `equals` / `not` against a `null` operand
|
|
91
86
|
* compile through `json_type` instead of `IS NULL` / `IS NOT NULL`.
|
|
92
87
|
*
|
|
93
88
|
* Every other MATCH-on-null-or-absent row is expressed uniformly (flat and
|
|
94
89
|
* nested alike) as `(<column> <op> ? OR <column> IS NULL)` — for a nested
|
|
95
|
-
* path, `json_extract` already collapses
|
|
90
|
+
* path, `json_extract` already collapses both absent and present-null to SQL
|
|
96
91
|
* `NULL`, so `IS NULL` catches both in one clause; for a flat column there is
|
|
97
92
|
* only the absent case to catch.
|
|
98
93
|
*
|
|
@@ -111,7 +106,8 @@ export declare function compileColumnSQL(storage: ColumnStorage): string;
|
|
|
111
106
|
export declare function compileConditionSQL(condition: Condition, schema: TableSchema): CompiledSQL;
|
|
112
107
|
|
|
113
108
|
/**
|
|
114
|
-
* Represents a parameterized SQL fragment or statement plus its bind values.
|
|
109
|
+
* Represents a parameterized SQL fragment or statement plus its bind values. The
|
|
110
|
+
* `@orkestrel/database/server` entry point exports this type.
|
|
115
111
|
*
|
|
116
112
|
* @remarks
|
|
117
113
|
* Produced by the pure SQL compilers (`compilers.ts`) that turn a core
|
|
@@ -128,15 +124,19 @@ export declare interface CompiledSQL {
|
|
|
128
124
|
/**
|
|
129
125
|
* Compiles a {@link FieldPath} to the SQL expression that reads it.
|
|
130
126
|
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* A flat path compiles to the quoted column; a nested path compiles to a
|
|
129
|
+
* `json_extract` over the head column with the rest of the path as its accessor.
|
|
130
|
+
*
|
|
131
131
|
* @param path - The field path
|
|
132
132
|
* @returns The SQL expression selecting the value
|
|
133
133
|
*/
|
|
134
134
|
export declare function compileFieldSQL(path: FieldPath): string;
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
|
-
* Compiles a
|
|
137
|
+
* Compiles a nested {@link FieldPath} to the `json_type(<col>, <path>)` SQL
|
|
138
138
|
* expression — the {@link compileFieldSQL} `json_extract` sibling used to tell a
|
|
139
|
-
*
|
|
139
|
+
* present JSON `null` apart from an absent path (both read back as SQL `NULL`
|
|
140
140
|
* through `json_extract`, but `json_type` reports `'null'` for the former and
|
|
141
141
|
* SQL `NULL` for the latter).
|
|
142
142
|
*
|
|
@@ -211,7 +211,7 @@ export declare function compilePageSQL(limit: number | undefined, offset: number
|
|
|
211
211
|
* `FieldPath` (a `json_extract` read) encodes each operand as the native scalar
|
|
212
212
|
* the extract returns — derived from the operand's runtime type — so it compares.
|
|
213
213
|
* Every operator maps per the databases guide's operator table, with
|
|
214
|
-
* `starts` / `ends` compiling to a
|
|
214
|
+
* `starts` / `ends` compiling to a code-point `substr` slice guarded by
|
|
215
215
|
* `typeof(<column>) = 'text'` (case-sensitive, matching the engine's
|
|
216
216
|
* `String.prototype.startsWith` / `endsWith`) and an empty `any` / `none` list
|
|
217
217
|
* collapsing to a constant. An `undefined` input (or one with no parts)
|
|
@@ -236,7 +236,7 @@ export declare function compileQuerySQL(input: QueryInput | undefined, schema: T
|
|
|
236
236
|
* @remarks
|
|
237
237
|
* The first condition's connector is ignored, per the {@link Condition} types.
|
|
238
238
|
* Every fragment (see {@link compileConditionSQL}'s truth table) replicates the core
|
|
239
|
-
* engine's total order
|
|
239
|
+
* engine's total order exactly under SQL's three-valued NULL logic, so this
|
|
240
240
|
* clause matches `applyQuery` row-for-row over the same table — a native
|
|
241
241
|
* `records` / `count` read never disagrees with a scan-and-filter fallback.
|
|
242
242
|
*
|
|
@@ -253,7 +253,7 @@ export declare function compileQuerySQL(input: QueryInput | undefined, schema: T
|
|
|
253
253
|
export declare function compileWhereSQL(conditions: readonly Condition[], schema: TableSchema): CompiledSQL;
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
|
-
* Creates a persistent JSON-file {@link DriverInterface} for
|
|
256
|
+
* Creates a persistent JSON-file {@link DriverInterface} for a given path.
|
|
257
257
|
*
|
|
258
258
|
* @remarks
|
|
259
259
|
* Pass it to `createDatabase` from `@orkestrel/database` to run the typed
|
|
@@ -285,7 +285,8 @@ export declare function compileWhereSQL(conditions: readonly Condition[], schema
|
|
|
285
285
|
export declare function createJSONDriver(path: string): DriverInterface;
|
|
286
286
|
|
|
287
287
|
/**
|
|
288
|
-
* Creates a trusted-mode SQLite {@link DriverInterface} for
|
|
288
|
+
* Creates a trusted-mode, server-native SQLite {@link DriverInterface} for a database path,
|
|
289
|
+
* or for `:memory:` when the options bag omits one.
|
|
289
290
|
*
|
|
290
291
|
* @remarks
|
|
291
292
|
* Pass it to `createDatabase` from `@orkestrel/database` to run the typed
|
|
@@ -371,7 +372,7 @@ export declare function decodeValue(value: SQLiteValue, column: ColumnSchema): u
|
|
|
371
372
|
* so a plan-built index name always matches one `open` would have created.
|
|
372
373
|
*
|
|
373
374
|
* @remarks
|
|
374
|
-
* A naive `idx_<table>_<cols joined by _>` is
|
|
375
|
+
* A naive `idx_<table>_<cols joined by _>` is ambiguous: table `'a_b'` with
|
|
375
376
|
* column `'c'` and table `'a'` with columns `['b', 'c']` both produce
|
|
376
377
|
* `idx_a_b_c`. This encodes each part (the table name, then each column name)
|
|
377
378
|
* length-prefixed (`<len>_<part>`) so the boundary between parts is always
|
|
@@ -431,28 +432,28 @@ export declare function encodeRow(row: Row, schema: TableSchema): SQLiteRow;
|
|
|
431
432
|
export declare function encodeValue(value: unknown, column: ColumnSchema): SQLiteValue;
|
|
432
433
|
|
|
433
434
|
/**
|
|
434
|
-
* Lists the declared {@link ColumnStorage}s whose SQL
|
|
435
|
+
* Lists the declared {@link ColumnStorage}s whose SQL equality comparisons (`equals` /
|
|
435
436
|
* `not` / `any` / `none`) and `starts` / `ends` compiles are provably
|
|
436
437
|
* engine-exact under declared-type trust — `text` / `integer` / `real` /
|
|
437
438
|
* `boolean`; a `json` or `blob` column always refines instead.
|
|
438
439
|
*
|
|
439
440
|
* @remarks
|
|
440
|
-
* This set governs equality and prefix/suffix matching only.
|
|
441
|
+
* This set governs equality and prefix/suffix matching only. Range
|
|
441
442
|
* comparisons (`above` / `below` / `from` / `to` / `between`) and `ORDER BY`
|
|
442
|
-
* are exact for `integer` / `real` / `boolean` but
|
|
443
|
+
* are exact for `integer` / `real` / `boolean` but not for `text`: compiled
|
|
443
444
|
* SQL orders/ranges under SQLite's default BINARY collation, which compares
|
|
444
|
-
* TEXT byte-for-byte as UTF-8 — equivalent to Unicode
|
|
445
|
+
* TEXT byte-for-byte as UTF-8 — equivalent to Unicode code-point order —
|
|
445
446
|
* while the core engine's `compareValues` orders JS strings with `<`, which
|
|
446
|
-
* compares UTF-16
|
|
447
|
+
* compares UTF-16 code-unit order. The two orders diverge for supplementary-
|
|
447
448
|
* plane characters (code points ≥ U+10000, for example many emoji): a lead surrogate
|
|
448
|
-
* (`\uD800`–`\uDBFF`) sorts
|
|
449
|
-
* its code point sorts
|
|
449
|
+
* (`\uD800`–`\uDBFF`) sorts below ``–`` in code-unit order, while
|
|
450
|
+
* its code point sorts above them. So `matchesConditionExactly`'s range family and
|
|
450
451
|
* `matchesOrderExactly` exclude `text`, refining through the core engine instead.
|
|
451
452
|
*/
|
|
452
453
|
export declare const EXACT_COLUMN_STORAGE: readonly ColumnStorage[];
|
|
453
454
|
|
|
454
455
|
/**
|
|
455
|
-
* Lists the declared {@link ColumnStorage}s whose SQL
|
|
456
|
+
* Lists the declared {@link ColumnStorage}s whose SQL range comparisons
|
|
456
457
|
* (`above` / `below` / `from` / `to` / `between`) and `ORDER BY` compiles are
|
|
457
458
|
* provably engine-exact — `integer` / `real` / `boolean` only. `text` is
|
|
458
459
|
* excluded: see {@link EXACT_COLUMN_STORAGE}'s remarks for the BINARY-collation
|
|
@@ -484,7 +485,7 @@ export declare function extractValues(row: SQLiteRow, names: readonly string[],
|
|
|
484
485
|
|
|
485
486
|
/**
|
|
486
487
|
* Reads the storage type a nested (`json_extract`) operand encodes as from its
|
|
487
|
-
*
|
|
488
|
+
* runtime value, never as `json`.
|
|
488
489
|
*
|
|
489
490
|
* @remarks
|
|
490
491
|
* `json_extract` returns the unquoted, natively-typed scalar (a JSON boolean as
|
|
@@ -541,17 +542,17 @@ export declare function inferValueStorage(value: unknown): ColumnStorage;
|
|
|
541
542
|
* remains an `ABORTED` `DatabaseError` in `context.cause`. The fail-closed read path
|
|
542
543
|
* ({@link JSONDriver.#document}) remains separate from this write-error contract.
|
|
543
544
|
*/
|
|
544
|
-
export declare class JSONDriver implements
|
|
545
|
+
export declare class JSONDriver implements DriverInterface {
|
|
545
546
|
#private;
|
|
546
547
|
constructor(path: string);
|
|
547
|
-
open(schema: readonly
|
|
548
|
+
open(schema: readonly TableSchema[]): Promise<void>;
|
|
548
549
|
close(): Promise<void>;
|
|
549
|
-
read(table: string, key: Key): Promise<
|
|
550
|
-
write(table: string, key: Key, row:
|
|
551
|
-
insert(table: string, key: Key, row:
|
|
550
|
+
read(table: string, key: Key): Promise<Row | undefined>;
|
|
551
|
+
write(table: string, key: Key, row: Row, options?: OperationOptions): Promise<void>;
|
|
552
|
+
insert(table: string, key: Key, row: Row, options?: OperationOptions): Promise<void>;
|
|
552
553
|
delete(table: string, key: Key, options?: OperationOptions): Promise<boolean>;
|
|
553
554
|
keys(table: string): Promise<readonly Key[]>;
|
|
554
|
-
scan(table: string): AsyncIterable<
|
|
555
|
+
scan(table: string): AsyncIterable<Row>;
|
|
555
556
|
/**
|
|
556
557
|
* Iterates rows lazily with native filtering — delegates to the inner {@link MemoryDriver}.
|
|
557
558
|
*
|
|
@@ -563,7 +564,7 @@ export declare class JSONDriver implements DriverInterface_2 {
|
|
|
563
564
|
* @param table - The table to stream
|
|
564
565
|
* @param input - The filter / offset / limit to apply lazily
|
|
565
566
|
*/
|
|
566
|
-
stream(table: string, input:
|
|
567
|
+
stream(table: string, input: QueryInput): AsyncIterable<Row>;
|
|
567
568
|
clear(table: string): Promise<void>;
|
|
568
569
|
/**
|
|
569
570
|
* Runs an isolated native transaction callback over a candidate memory store.
|
|
@@ -660,7 +661,7 @@ export declare function matchesAbsentPath(error: unknown): boolean;
|
|
|
660
661
|
export declare function matchesAggregateExactly(operation: AggregateOperation, column: FieldPath, schema: TableSchema): boolean;
|
|
661
662
|
|
|
662
663
|
/**
|
|
663
|
-
* Reports whether one {@link Condition} compiles to SQL that is
|
|
664
|
+
* Reports whether one {@link Condition} compiles to SQL that is provably
|
|
664
665
|
* identical to the core engine's `matchesCondition` for every value its
|
|
665
666
|
* column's declared type can store.
|
|
666
667
|
*
|
|
@@ -674,18 +675,18 @@ export declare function matchesAggregateExactly(operation: AggregateOperation, c
|
|
|
674
675
|
* Required non-null `equals` / `not` require an operand matching the declared
|
|
675
676
|
* storage and exclude `json` / `blob`. `above` / `below` / `from` / `to` /
|
|
676
677
|
* `between` are exact only for {@link EXACT_RANGE_COLUMN_STORAGE} (`integer` /
|
|
677
|
-
* `real` / `boolean`) — a `text` column's range conditions
|
|
678
|
-
* SQLite's default BINARY collation orders TEXT by Unicode
|
|
679
|
-
* the core engine's `compareValues` orders JS strings by UTF-16
|
|
678
|
+
* `real` / `boolean`) — a `text` column's range conditions refine, because
|
|
679
|
+
* SQLite's default BINARY collation orders TEXT by Unicode code point while
|
|
680
|
+
* the core engine's `compareValues` orders JS strings by UTF-16 code unit,
|
|
680
681
|
* and the two diverge for supplementary-plane characters (see
|
|
681
682
|
* {@link EXACT_COLUMN_STORAGE}'s remarks for the full rationale).
|
|
682
|
-
* `any` / `none` require a
|
|
683
|
+
* `any` / `none` require a non-empty list where every element matches (an empty
|
|
683
684
|
* list is exact under neither: the engine's `any([])` matches nothing while
|
|
684
685
|
* `none([])` matches everything, and SQL `IN ()` is a syntax error) — these
|
|
685
686
|
* stay exact on `text` (byte equality is collation-independent and engine-
|
|
686
687
|
* identical). `starts` / `ends` are exact only on a `text` column with a
|
|
687
688
|
* string operand (case-sensitive `substr` compile, see {@link compileConditionSQL}) —
|
|
688
|
-
* likewise collation-independent. `like` / `glob` are
|
|
689
|
+
* likewise collation-independent. `like` / `glob` are never exact — SQLite
|
|
689
690
|
* `LIKE` folds case ASCII-only against the engine's Unicode fold, and `GLOB`
|
|
690
691
|
* has character classes the engine treats literally.
|
|
691
692
|
*
|
|
@@ -700,7 +701,7 @@ export declare function matchesConditionExactly(condition: Condition, schema: Ta
|
|
|
700
701
|
* — the operand side of the declared-type-trust proof.
|
|
701
702
|
*
|
|
702
703
|
* @remarks
|
|
703
|
-
* `text` ↔ string, `integer` / `real` ↔
|
|
704
|
+
* `text` ↔ string, `integer` / `real` ↔ finite number (`NaN` / `±Infinity`
|
|
704
705
|
* fail), `boolean` ↔ boolean. Backs {@link matchesConditionExactly}'s operand checks.
|
|
705
706
|
*
|
|
706
707
|
* @param value - The condition operand to test
|
|
@@ -717,16 +718,19 @@ export declare function matchesDeclaredStorage(value: unknown, storage: ColumnSt
|
|
|
717
718
|
|
|
718
719
|
/**
|
|
719
720
|
* Reports whether one {@link Order} term's column compiles to an `ORDER BY`
|
|
720
|
-
* that matches the engine's {@link import('@
|
|
721
|
+
* that matches the engine's {@link import('@orkestrel/database').sortRows} exactly.
|
|
721
722
|
*
|
|
722
723
|
* @remarks
|
|
723
724
|
* `false` for a nested `FieldPath`, a column absent from `schema`, or a
|
|
724
725
|
* declared type outside {@link EXACT_RANGE_COLUMN_STORAGE} (`integer` / `real` /
|
|
725
|
-
* `boolean`). `text` is
|
|
726
|
+
* `boolean`). `text` is not exact here: SQLite's default BINARY collation
|
|
726
727
|
* orders TEXT by Unicode code point while the core engine's `compareValues`
|
|
727
728
|
* orders JS strings by UTF-16 code unit, and the two diverge for
|
|
728
729
|
* supplementary-plane characters (see {@link EXACT_COLUMN_STORAGE}'s remarks) —
|
|
729
|
-
* a `text` order term
|
|
730
|
+
* a `text` order term refines through the core engine instead. The column must
|
|
731
|
+
* also be required and non-null: an optional or nullable column refines, because
|
|
732
|
+
* SQL orders its `NULL`s ahead of every value while the core total order ranks
|
|
733
|
+
* `undefined` before `null` before every other value.
|
|
730
734
|
*
|
|
731
735
|
* @param order - The order term to test
|
|
732
736
|
* @param schema - The table's schema
|
|
@@ -739,6 +743,10 @@ export declare function matchesOrderExactly(order: Order, schema: TableSchema):
|
|
|
739
743
|
* every order term is exact. `limit` / `offset` never affect exactness (SQL
|
|
740
744
|
* `LIMIT` / `OFFSET` are always engine-identical).
|
|
741
745
|
*
|
|
746
|
+
* @remarks
|
|
747
|
+
* The gate {@link import('./drivers/SQLiteDriver.js').SQLiteDriver} checks before
|
|
748
|
+
* trusting a native SQL read over a full-scan refine through the core engine.
|
|
749
|
+
*
|
|
742
750
|
* @param input - The query input to test
|
|
743
751
|
* @param schema - The table's schema
|
|
744
752
|
* @returns True if every part of `input` is exact; false otherwise
|
|
@@ -786,6 +794,10 @@ export declare function quoteIdentifier(identifier: string): string;
|
|
|
786
794
|
/**
|
|
787
795
|
* Projects a {@link TableSchema} to its declared SQLite indexes.
|
|
788
796
|
*
|
|
797
|
+
* @remarks
|
|
798
|
+
* Each statement is a `CREATE INDEX IF NOT EXISTS` named by
|
|
799
|
+
* {@link deriveSQLiteIndexName}, so a reopen re-issues the set safely.
|
|
800
|
+
*
|
|
789
801
|
* @param schema - The table schema
|
|
790
802
|
* @returns One statement per declared index
|
|
791
803
|
*/
|
|
@@ -847,21 +859,21 @@ export declare function schemaToTable(schema: TableSchema): string;
|
|
|
847
859
|
* from a migration-plan fault) passes through `#guard` unchanged, never
|
|
848
860
|
* re-wrapped.
|
|
849
861
|
*/
|
|
850
|
-
export declare class SQLiteDriver implements
|
|
862
|
+
export declare class SQLiteDriver implements DriverInterface {
|
|
851
863
|
#private;
|
|
852
864
|
constructor(options?: SQLiteDriverOptions);
|
|
853
|
-
open(schema: readonly
|
|
865
|
+
open(schema: readonly TableSchema[]): Promise<void>;
|
|
854
866
|
close(): Promise<void>;
|
|
855
|
-
read(table: string, key: Key): Promise<
|
|
856
|
-
write(table: string, key: Key, row:
|
|
857
|
-
insert(table: string, key: Key, row:
|
|
867
|
+
read(table: string, key: Key): Promise<Row | undefined>;
|
|
868
|
+
write(table: string, key: Key, row: Row, options?: OperationOptions): Promise<void>;
|
|
869
|
+
insert(table: string, key: Key, row: Row, options?: OperationOptions): Promise<void>;
|
|
858
870
|
delete(table: string, key: Key, options?: OperationOptions): Promise<boolean>;
|
|
859
871
|
keys(table: string): Promise<readonly Key[]>;
|
|
860
|
-
scan(table: string): AsyncIterable<
|
|
872
|
+
scan(table: string): AsyncIterable<Row>;
|
|
861
873
|
clear(table: string): Promise<void>;
|
|
862
|
-
records(table: string, input:
|
|
863
|
-
aggregate(table: string, operation:
|
|
864
|
-
stream(table: string, input:
|
|
874
|
+
records(table: string, input: QueryInput): Promise<readonly Row[]>;
|
|
875
|
+
aggregate(table: string, operation: AggregateOperation, column: FieldPath, input: QueryInput): Promise<number | undefined>;
|
|
876
|
+
stream(table: string, input: QueryInput): AsyncIterable<Row>;
|
|
865
877
|
/**
|
|
866
878
|
* Begins a native transaction — real `BEGIN`, `COMMIT`, `ROLLBACK`.
|
|
867
879
|
*
|
|
@@ -918,7 +930,8 @@ export declare class SQLiteDriver implements DriverInterface_2 {
|
|
|
918
930
|
}
|
|
919
931
|
|
|
920
932
|
/**
|
|
921
|
-
*
|
|
933
|
+
* Configures {@link import('./factories.js').createSQLiteDriver}. The
|
|
934
|
+
* `@orkestrel/database/server` entry point exports this type.
|
|
922
935
|
*
|
|
923
936
|
* @remarks
|
|
924
937
|
* Threaded into the underlying `@orkestrel/sqlite` wrapper's connection.
|
|
@@ -945,6 +958,10 @@ export declare interface SQLiteDriverOptions {
|
|
|
945
958
|
/**
|
|
946
959
|
* Projects one {@link MigrationStep} to SQLite DDL.
|
|
947
960
|
*
|
|
961
|
+
* @remarks
|
|
962
|
+
* These are the statements the SQLite driver's `migrate` executes for the step,
|
|
963
|
+
* inside whichever native transaction is active.
|
|
964
|
+
*
|
|
948
965
|
* @param step - The migration step
|
|
949
966
|
* @returns The statements that apply the step
|
|
950
967
|
*/
|