@xwxfox/foxdb 0.1.2 → 0.1.3

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/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { TSchema as TSchema6 } from "typebox";
2
- import { TObject as TObject2, TArray, TSchema as TSchema2, TProperties, TOptional as TOptional2, Static } from "typebox";
1
+ import { TSchema as TSchema10 } from "typebox";
2
+ import { TObject as TObject2, TArray, TSchema as TSchema2, TProperties, TOptional as TOptional2, TString as TString2, TLiteral as TLiteral2, Static } from "typebox";
3
3
  import { TObject, TString, TNumber, TInteger, TBoolean, TLiteral, TSchema, TOptional } from "typebox";
4
4
  /** @category Schema */
5
5
  type TScalarSchema = TString | TNumber | TInteger | TBoolean | TLiteral<string> | TLiteral<number> | TLiteral<boolean>;
@@ -53,7 +53,16 @@ interface TypedRelation<
53
53
  kind: K;
54
54
  as: A;
55
55
  }
56
- import { Database, Statement } from "bun:sqlite";
56
+ import { Database, SQLQueryBindings, Statement } from "bun:sqlite";
57
+ type SweepTask = () => void;
58
+ declare class TableScheduler {
59
+ private timers;
60
+ private timersByName;
61
+ private tasks;
62
+ schedule(name: string, intervalMs: number, task: SweepTask): void;
63
+ clear(name: string): void;
64
+ clearAll(): void;
65
+ }
57
66
  /**
58
67
  * prepared sqlite statement
59
68
  * @category Database
@@ -92,7 +101,10 @@ declare class BunDatabase {
92
101
  /** underlying bun:sqlite database */
93
102
  readonly db: Database;
94
103
  /** scheduler for table maintenance tasks */
95
- readonly scheduler;
104
+ readonly scheduler: TableScheduler;
105
+ private extensionStatus;
106
+ /** Tracks nesting depth of user-initiated transactions */
107
+ _txDepth: number;
96
108
  constructor(opts?: DatabaseOptions);
97
109
  /** execute ddl (create table, index, etc) */
98
110
  exec(sql: string): void;
@@ -106,8 +118,18 @@ declare class BunDatabase {
106
118
  prepare(sql: string): BunStatement;
107
119
  /** set synchronous pragma for bulk load or normal operation */
108
120
  setSynchronous(mode: "OFF" | "NORMAL" | "FULL" | "EXTRA"): void;
121
+ /**
122
+ * Drop one cached statement without finalizing it. Recovery path for
123
+ * holders (see QueryExecutor) whose cached object was finalized
124
+ * out-of-band: the shared entry may reference the same dead object, so
125
+ * it must go too, otherwise the next prepare() would hand the corpse
126
+ * right back.
127
+ */
128
+ dropCached(sql: string): void;
109
129
  /** clear the statement cache */
110
130
  clearCache(): void;
131
+ /** get stmt stats from extension. Returns [] if ran without --feature DEBUG_SQL_BUILDING */
132
+ getStmtStats(sql: string): unknown;
111
133
  }
112
134
  type JsonValue = null | boolean | number | string | JsonValue[] | {
113
135
  [key: string]: JsonValue;
@@ -485,6 +507,54 @@ interface CursorPageResult<T> {
485
507
  type SelectableKeys<T extends TSchema2 & {
486
508
  properties: Record<string, TSchema2>;
487
509
  }> = ScalarKeys<T> | ObjectKeys<T> | PrimitiveArrayKeys<T> | JsonPath<T>;
510
+ type FilterableFields<T extends TSchema2 & {
511
+ properties: Record<string, TSchema2>;
512
+ }> = ScalarKeys<T> | ObjectKeys<T> | ScalarJsonPath<T> | SubTableScalarPath<T>;
513
+ /**
514
+ * Filterable fields excluding sub-table paths.
515
+ * Used when no sub-tables have been included via .include().
516
+ * @category Query Types
517
+ */
518
+ type FilterableFieldsBase<T extends TSchema2 & {
519
+ properties: Record<string, TSchema2>;
520
+ }> = ScalarKeys<T> | ObjectKeys<T> | ScalarJsonPath<T>;
521
+ /**
522
+ * Filterable fields that include ONLY sub-table paths for the specified tables.
523
+ * @internal
524
+ */
525
+ type IncludedSubTablePaths<
526
+ T extends TSchema2 & {
527
+ properties: Record<string, TSchema2>;
528
+ },
529
+ I extends string
530
+ > = Extract<SubTableScalarPath<T>, `${I}.${string}`>;
531
+ type FilterableForInclude<
532
+ T extends TSchema2 & {
533
+ properties: Record<string, TSchema2>;
534
+ },
535
+ I extends string | undefined
536
+ > = [I] extends [never] ? FilterableFieldsBase<T> : [I] extends [undefined] ? FilterableFieldsBase<T> : FilterableFieldsBase<T> | IncludedSubTablePaths<T, I & string>;
537
+ type FieldType<
538
+ T extends TSchema2 & {
539
+ properties: Record<string, TSchema2>;
540
+ },
541
+ P extends FilterableFields<T>
542
+ > = PathValue<T, P>;
543
+ type ArrayFilterableFields<T extends TSchema2 & {
544
+ properties: Record<string, TSchema2>;
545
+ }> = PrimitiveArrayKeys<T>;
546
+ type ArrayItemType<
547
+ T extends TSchema2 & {
548
+ properties: Record<string, TSchema2>;
549
+ },
550
+ P extends ArrayFilterableFields<T>
551
+ > = UnwrapOptional<T["properties"][P]> extends TArray<infer Item> ? Static<Item> : never;
552
+ type OrderableFields<T extends TSchema2 & {
553
+ properties: Record<string, TSchema2>;
554
+ }> = ScalarKeys<T> | ScalarJsonPath<T>;
555
+ type DistinctableFields<T extends TSchema2 & {
556
+ properties: Record<string, TSchema2>;
557
+ }> = ScalarKeys<T> | ScalarJsonPath<T>;
488
558
  interface FindOptions<T extends TSchema2 & {
489
559
  properties: Record<string, TSchema2>;
490
560
  }> extends PaginationOptions {
@@ -591,6 +661,39 @@ interface CompressionConfig {
591
661
  interface SoftDeleteConfig {
592
662
  column: string;
593
663
  }
664
+ /**
665
+ * Full-text search configuration for a table.
666
+ * - `true` indexes every TEXT column.
667
+ * - `{ columns }` indexes an explicit, type-checked column list.
668
+ * @category Schema
669
+ */
670
+ type FTSConfig = true | {
671
+ /** Columns to index. Omit to index all TEXT columns. */
672
+ columns?: readonly ColumnRef<string, TScalarSchema>[];
673
+ /** FTS5 tokenizer directive, e.g. "porter unicode61", "trigram". Default: "unicode61". */
674
+ tokenizer?: string;
675
+ /** FTS5 prefix-index sizes, e.g. [2, 3]. */
676
+ prefix?: readonly number[];
677
+ };
678
+ /** True when a table has FTS enabled. @internal */
679
+ type FTSEnabled<F> = [F] extends [undefined] ? false : [F] extends [never] ? false : true;
680
+ /** Union of flattened TEXT column names (top-level + nested `a__b`). @internal */
681
+ type FTSAllTextFields<T extends TSchema2 & {
682
+ properties: Record<string, TSchema2>;
683
+ }> = { [K in keyof ColumnRefs<T>] : ColumnRefs<T>[K] extends ColumnRef<infer N, infer S> ? S extends TString2 ? N : S extends TLiteral2<string> ? N : never : never }[keyof ColumnRefs<T>];
684
+ /** Names extracted from an explicit `{ columns }` FTS config. @internal */
685
+ type FTSConfiguredFields<F> = F extends {
686
+ columns: readonly (infer C)[];
687
+ } ? C extends ColumnRef<infer N, TScalarSchema> ? N : never : never;
688
+ /** The searchable field-name union for a table given its FTS config. @internal */
689
+ type FTSFields<
690
+ T extends TSchema2 & {
691
+ properties: Record<string, TSchema2>;
692
+ },
693
+ F
694
+ > = [F] extends [undefined] ? never : [F] extends [false] ? never : F extends {
695
+ columns: readonly ColumnRef<string, TScalarSchema>[];
696
+ } ? FTSConfiguredFields<F> : FTSAllTextFields<T>;
594
697
  type GeneratedColumnConfig = {
595
698
  [name: string]: {
596
699
  expr: string;
@@ -618,7 +721,8 @@ interface TableConfig<
618
721
  },
619
722
  PK extends string = string,
620
723
  TS extends TimestampConfig = undefined,
621
- G extends GeneratedColumnConfig | undefined = undefined
724
+ G extends GeneratedColumnConfig | undefined = undefined,
725
+ F extends FTSConfig | undefined = undefined
622
726
  > {
623
727
  schema: T;
624
728
  primaryKey: ColumnRef<PK>;
@@ -631,6 +735,9 @@ interface TableConfig<
631
735
  compression?: CompressionConfig;
632
736
  softDelete?: SoftDeleteConfig;
633
737
  generated?: G;
738
+ fts?: F;
739
+ /** Auto-index TEXT columns on sub-tables. Defaults to false. Set true to enable. */
740
+ autoIndex?: boolean;
634
741
  }
635
742
  /**
636
743
  * read-only metadata about the current database schema
@@ -648,7 +755,7 @@ interface MetaAccessors {
648
755
  * @category Relations
649
756
  */
650
757
  interface RelationEntry<
651
- Tables extends Record<string, TableConfig<any, any, any, any>>,
758
+ Tables extends Record<string, TableConfig<any, any, any, any, any>>,
652
759
  Owner extends keyof Tables,
653
760
  Target extends keyof Tables
654
761
  > {
@@ -660,7 +767,7 @@ interface RelationEntry<
660
767
  * @internal
661
768
  * @category Relations
662
769
  */
663
- type RelationsConfig<Tables extends Record<string, TableConfig<any, any, any, any>>> = { [K in keyof Tables & string]? : Array<{ [Target in keyof Tables & string] : RelationEntry<Tables, K, Target> }[keyof Tables & string]> };
770
+ type RelationsConfig<Tables extends Record<string, TableConfig<any, any, any, any, any>>> = { [K in keyof Tables & string]? : Array<{ [Target in keyof Tables & string] : RelationEntry<Tables, K, Target> }[keyof Tables & string]> };
664
771
  /**
665
772
  * @internal
666
773
  * @category Relations
@@ -677,7 +784,7 @@ type ScalarMergeNames<
677
784
  * @category Relations
678
785
  */
679
786
  type ScalarMergeType<
680
- Tables extends Record<string, TableConfig<any, any, any, any>>,
787
+ Tables extends Record<string, TableConfig<any, any, any, any, any>>,
681
788
  Rels extends readonly TypedRelation[],
682
789
  Owner extends string,
683
790
  Name extends string
@@ -691,7 +798,7 @@ type ScalarMergeType<
691
798
  * @category Relations
692
799
  */
693
800
  type ScalarMerge<
694
- Tables extends Record<string, TableConfig<any, any, any, any>>,
801
+ Tables extends Record<string, TableConfig<any, any, any, any, any>>,
695
802
  Rels extends readonly TypedRelation[],
696
803
  Owner extends string
697
804
  > = { [K in ScalarMergeNames<Rels, Owner>] : ScalarMergeType<Tables, Rels, Owner, K> };
@@ -713,7 +820,7 @@ type SubMergeNames<
713
820
  * @category Relations
714
821
  */
715
822
  type SubMergeType<
716
- Tables extends Record<string, TableConfig<any, any, any, any>>,
823
+ Tables extends Record<string, TableConfig<any, any, any, any, any>>,
717
824
  Rels extends readonly TypedRelation[],
718
825
  Owner extends string,
719
826
  Sub extends string,
@@ -729,7 +836,7 @@ type SubMergeType<
729
836
  * @category Relations
730
837
  */
731
838
  type SubMerge<
732
- Tables extends Record<string, TableConfig<any, any, any, any>>,
839
+ Tables extends Record<string, TableConfig<any, any, any, any, any>>,
733
840
  Rels extends readonly TypedRelation[],
734
841
  Owner extends string,
735
842
  Sub extends string
@@ -754,7 +861,7 @@ type Materialized<
754
861
  T extends TSchema2 & {
755
862
  properties: Record<string, TSchema2>;
756
863
  },
757
- Tables extends Record<string, TableConfig<any, any, any, any>>,
864
+ Tables extends Record<string, TableConfig<any, any, any, any, any>>,
758
865
  Rels extends readonly TypedRelation[],
759
866
  Owner extends string
760
867
  > = { [K in keyof Infer<T>] : K extends string ? Infer<T>[K] extends Array<infer Item> ? Array<Item & SubMerge<Tables, Rels, Owner, K>> : Infer<T>[K] : Infer<T>[K] } & ScalarMerge<Tables, Rels, Owner>;
@@ -1077,7 +1184,7 @@ type ErrorPolicy = "throw" | "emit" | "emit-swallow" | "crash";
1077
1184
  * @category Setup
1078
1185
  */
1079
1186
  type UnlinkPolicy = true | "onlyGraceful" | "any" | false | undefined;
1080
- import { TSchema as TSchema5 } from "typebox";
1187
+ import { TSchema as TSchema8 } from "typebox";
1081
1188
  import { TSchema as TSchema3 } from "typebox";
1082
1189
  /** @category Schema */
1083
1190
  interface SubTableConfig {
@@ -1089,12 +1196,14 @@ interface TableDescriptor<
1089
1196
  },
1090
1197
  PK extends string,
1091
1198
  TS extends TimestampConfig = undefined,
1092
- G extends GeneratedColumnConfig | undefined = undefined
1093
- > extends TableConfig<T, PK, TS, G> {}
1199
+ G extends GeneratedColumnConfig | undefined = undefined,
1200
+ F extends FTSConfig | undefined = undefined
1201
+ > extends TableConfig<T, PK, TS, G, F> {}
1094
1202
  interface TableConfigShape<
1095
1203
  PK extends string,
1096
1204
  TS extends TimestampConfig,
1097
- G extends GeneratedColumnConfig | undefined = undefined
1205
+ G extends GeneratedColumnConfig | undefined = undefined,
1206
+ F extends FTSConfig | undefined = undefined
1098
1207
  > {
1099
1208
  primaryKey: ColumnRef<PK>;
1100
1209
  indexes?: IndexDefinition[];
@@ -1104,6 +1213,9 @@ interface TableConfigShape<
1104
1213
  compression?: CompressionConfig;
1105
1214
  softDelete?: SoftDeleteConfig;
1106
1215
  generated?: G;
1216
+ fts?: F;
1217
+ /** Auto-index TEXT columns on sub-tables. Defaults to false. Set true to enable. */
1218
+ autoIndex?: boolean;
1107
1219
  }
1108
1220
  /**
1109
1221
  * Describe a table schema + config for `createORM`.
@@ -1127,8 +1239,9 @@ declare function table<
1127
1239
  },
1128
1240
  PK extends string,
1129
1241
  TS extends TimestampConfig = undefined,
1130
- G extends GeneratedColumnConfig | undefined = undefined
1131
- >(schema: T, configure: (columns: ColumnRefs<T>) => TableConfigShape<PK, TS, G>): TableDescriptor<T, PK, TS, G>;
1242
+ G extends GeneratedColumnConfig | undefined = undefined,
1243
+ const F extends FTSConfig | undefined = undefined
1244
+ >(schema: T, configure: (columns: ColumnRefs<T>) => TableConfigShape<PK, TS, G, F>): TableDescriptor<T, PK, TS, G, F>;
1132
1245
  /** @category Events */
1133
1246
  type Listener = (payload: unknown) => void;
1134
1247
  /**
@@ -1162,7 +1275,7 @@ interface LifecycleEventMap {
1162
1275
  * typed event listener api
1163
1276
  * @category Events
1164
1277
  */
1165
- interface ORMEvents<Tables extends Record<string, TableDescriptor<any, any, any, any>>> {
1278
+ interface ORMEvents<Tables extends Record<string, TableDescriptor<any, any, any, any, any>>> {
1166
1279
  /** listen to lifecycle events (start, ready, shutdown, exit, fail) */
1167
1280
  on<K extends (keyof LifecycleEventMap) & string>(event: K, listener: (payload: LifecycleEventMap[K]) => void): () => void;
1168
1281
  /** listen to table events (insert, update, findMany, etc) */
@@ -1187,6 +1300,18 @@ declare class EventBus {
1187
1300
  import { TSchema as TSchema4 } from "typebox";
1188
1301
  /** @category Advanced */
1189
1302
  type SqliteType = "TEXT" | "INTEGER" | "REAL" | "BLOB";
1303
+ /**
1304
+ * Pre-classified decode strategy for hydration.
1305
+ * Avoids per-value heuristic checks by knowing the column's type at schema time.
1306
+ */
1307
+ declare const enum ColDecode {
1308
+ /** Scalar string or number – pass through, no processing */
1309
+ Scalar = 0,
1310
+ /** JSON object/array stored as TEXT – always JSON.parse */
1311
+ Json = 1,
1312
+ /** Boolean stored as INTEGER – convert 0/1 to false/true */
1313
+ Bool = 2
1314
+ }
1190
1315
  /** @category Advanced */
1191
1316
  interface ColumnMeta {
1192
1317
  name: string;
@@ -1202,22 +1327,44 @@ interface ColumnMeta {
1202
1327
  generated?: boolean;
1203
1328
  /** Expression for generated columns */
1204
1329
  generatedExpr?: string;
1330
+ /** Pre-built getter function for flattenRow (set during introspectTable) */
1331
+ _get?: (obj: Record<string, unknown>) => unknown;
1332
+ /**
1333
+ * Pre-classified decode strategy for hydration.
1334
+ * Scalar=0 (no processing), Json=1 (JSON.parse), Bool=2 (v===1).
1335
+ */
1336
+ decode?: ColDecode;
1337
+ /**
1338
+ * If path.length <= 1, pre-stored target key for direct property assignment
1339
+ * (avoids branching in the hydration hot loop).
1340
+ */
1341
+ _targetKey?: string;
1205
1342
  }
1206
- /** @category Advanced */
1207
- interface SubTableMeta {
1208
- /** e.g. "lineItems" */
1343
+ type SubTableMetaCommon = {
1209
1344
  fieldName: string;
1210
- /** e.g. "sales__lineItems" */
1211
1345
  tableName: string;
1212
- /** Schema of a single item in the array */
1213
- itemSchema: TSchema4 & {
1214
- properties: Record<string, TSchema4>;
1215
- };
1216
- /** Columns of the sub-table row (owner PK is prepended automatically) */
1217
1346
  columns: ColumnMeta[];
1218
1347
  columnByName: Map<string, ColumnMeta>;
1219
1348
  columnByPath: Map<string, ColumnMeta>;
1220
- }
1349
+ /** Pre-built INSERT column SQL fragment, e.g. `"_owner_id", "_index", "col1", "col2"` */
1350
+ insertColsSql?: string;
1351
+ /** Pre-built INSERT value group fragment, e.g. `(?, ?, ?, ?)` */
1352
+ insertValueGroup?: string;
1353
+ /** Ordered column names for INSERT */
1354
+ insertColumnNames?: string[];
1355
+ };
1356
+ /** @category Advanced */
1357
+ type SubTableMeta = SubTableMetaCommon & ({
1358
+ isScalar: true;
1359
+ scalarType: SqliteType;
1360
+ itemSchema?: never;
1361
+ } | {
1362
+ isScalar?: false;
1363
+ scalarType?: never;
1364
+ itemSchema?: TSchema4 & {
1365
+ properties: Record<string, TSchema4>;
1366
+ };
1367
+ });
1221
1368
  /** @category Advanced */
1222
1369
  interface TableMeta {
1223
1370
  tableName: string;
@@ -1227,6 +1374,17 @@ interface TableMeta {
1227
1374
  columnByPath: Map<string, ColumnMeta>;
1228
1375
  /** Map from column name → ColumnMeta for O(1) resolution */
1229
1376
  columnByName: Map<string, ColumnMeta>;
1377
+ /** The PK column name of the parent table - used for sub-table filter SQL */
1378
+ primaryKey?: string;
1379
+ /** Non-generated columns - pre-filtered for flattenRow / INSERT / UPDATE */
1380
+ insertColumns: ColumnMeta[];
1381
+ /** Precomputed ordered column names for INSERT SQL */
1382
+ insertColumnNames: string[];
1383
+ /**
1384
+ * Pre-compiled fast hydration function (no codecs, no select/include filtering).
1385
+ * Populated by introspectTable. Use hydrateRowFastCompiled for the common path.
1386
+ */
1387
+ _hydrateFast?: (flat: Record<string, unknown>) => Record<string, unknown>;
1230
1388
  }
1231
1389
  /** @category Advanced */
1232
1390
  declare function introspectTable(tableName: string, schema: TSchema4 & {
@@ -1235,9 +1393,256 @@ declare function introspectTable(tableName: string, schema: TSchema4 & {
1235
1393
  name: string;
1236
1394
  expr: string;
1237
1395
  sqlType?: SqliteType;
1238
- }>): TableMeta;
1396
+ }>, primaryKey?: string): TableMeta;
1239
1397
  /** @category Advanced */
1240
- declare function buildCreateTableSQL(meta: TableMeta, primaryKey: string): string[];
1398
+ declare function buildCreateTableSQL(meta: TableMeta, primaryKey: string, autoIndex?: boolean, onDeleteBehavior?: "native" | "foxdb" | "none"): string[];
1399
+ import { TSchema as TSchema6 } from "typebox";
1400
+ /**
1401
+ * Runtime shape of any filter - independent of the column's value type
1402
+ */
1403
+ type FilterShape = {
1404
+ eq: unknown;
1405
+ } | {
1406
+ ne: unknown;
1407
+ } | {
1408
+ gt: unknown;
1409
+ } | {
1410
+ gte: unknown;
1411
+ } | {
1412
+ lt: unknown;
1413
+ } | {
1414
+ lte: unknown;
1415
+ } | {
1416
+ like: string;
1417
+ } | {
1418
+ between: [unknown, unknown];
1419
+ } | {
1420
+ in: readonly unknown[];
1421
+ } | {
1422
+ notIn: readonly unknown[];
1423
+ } | {
1424
+ isNull: true;
1425
+ } | {
1426
+ isNotNull: true;
1427
+ } | {
1428
+ arraySome: unknown;
1429
+ } | {
1430
+ arrayNot: unknown;
1431
+ } | {
1432
+ isEmpty: boolean;
1433
+ } | {
1434
+ fastArraySome: unknown;
1435
+ } | {
1436
+ fastArrayNot: unknown;
1437
+ } | {
1438
+ fastArrayIsEmpty: boolean;
1439
+ };
1440
+ interface WhereResult {
1441
+ sql: string;
1442
+ params: SQLQueryBindings[];
1443
+ }
1444
+ type ConditionNode = {
1445
+ type: "condition";
1446
+ field: string;
1447
+ filter: FilterShape;
1448
+ } | {
1449
+ type: "raw";
1450
+ sql: string;
1451
+ params: SQLQueryBindings[];
1452
+ } | {
1453
+ type: "and";
1454
+ children: ConditionNode[];
1455
+ } | {
1456
+ type: "or";
1457
+ children: ConditionNode[];
1458
+ } | {
1459
+ type: "not";
1460
+ child: ConditionNode;
1461
+ } | {
1462
+ type: "nested";
1463
+ field: string;
1464
+ children: ConditionNode[];
1465
+ };
1466
+ interface InternalBuilderState {
1467
+ nodes: ConditionNode[];
1468
+ orderBy: Array<{
1469
+ column: string;
1470
+ direction: "ASC" | "DESC";
1471
+ }>;
1472
+ limit: number | undefined;
1473
+ offset: number | undefined;
1474
+ select: string[] | undefined;
1475
+ include: string[] | undefined;
1476
+ includeDeleted: boolean;
1477
+ distinct: boolean;
1478
+ distinctOn: string[] | undefined;
1479
+ }
1480
+ interface AggregateBuilderState {
1481
+ aggregations: Record<string, {
1482
+ op: string;
1483
+ field: string;
1484
+ }>;
1485
+ groupBy: string[] | undefined;
1486
+ having: ConditionNode[];
1487
+ includeDeleted: boolean;
1488
+ }
1489
+ declare function buildWhereFromNodes(nodes: ConditionNode[], softDeleteColumn: string | undefined, meta: TableMeta | undefined): WhereResult;
1490
+ declare class FilterBuilder<
1491
+ TQuery extends TSchema6 & {
1492
+ properties: Record<string, TSchema6>;
1493
+ },
1494
+ TResult,
1495
+ I extends SubTableKeys<TQuery> | undefined = undefined
1496
+ > {
1497
+ private _executor?;
1498
+ private _asyncExecutor?;
1499
+ _nodes: ConditionNode[];
1500
+ private _orderByFields;
1501
+ private _limitValue;
1502
+ private _offsetValue;
1503
+ private _selectFields;
1504
+ private _includeFields;
1505
+ private _includeDeletedValue;
1506
+ private _distinctValue;
1507
+ private _distinctOnFields;
1508
+ constructor(_executor?: ((state: InternalBuilderState) => TResult) | undefined, _asyncExecutor?: ((state: InternalBuilderState) => Promise<TResult>) | undefined);
1509
+ private _assertExecutor;
1510
+ private _collectState;
1511
+ equals<P extends FilterableForInclude<TQuery, I>>(field: P, value: FieldType<TQuery, P>): this;
1512
+ notEquals<P extends FilterableForInclude<TQuery, I>>(field: P, value: FieldType<TQuery, P>): this;
1513
+ greaterThan<P extends FilterableForInclude<TQuery, I>>(field: P, value: FieldType<TQuery, P>): this;
1514
+ greaterThanOrEqual<P extends FilterableForInclude<TQuery, I>>(field: P, value: FieldType<TQuery, P>): this;
1515
+ lessThan<P extends FilterableForInclude<TQuery, I>>(field: P, value: FieldType<TQuery, P>): this;
1516
+ lessThanOrEqual<P extends FilterableForInclude<TQuery, I>>(field: P, value: FieldType<TQuery, P>): this;
1517
+ between<P extends FilterableForInclude<TQuery, I>>(field: P, min: FieldType<TQuery, P>, max: FieldType<TQuery, P>): this;
1518
+ like<P extends FilterableForInclude<TQuery, I>>(field: P, pattern: string): this;
1519
+ contains<P extends FilterableForInclude<TQuery, I>>(field: P, substring: string): this;
1520
+ startsWith<P extends FilterableForInclude<TQuery, I>>(field: P, prefix: string): this;
1521
+ endsWith<P extends FilterableForInclude<TQuery, I>>(field: P, suffix: string): this;
1522
+ in<P extends FilterableForInclude<TQuery, I>>(field: P, values: FieldType<TQuery, P>[]): this;
1523
+ notIn<P extends FilterableForInclude<TQuery, I>>(field: P, values: FieldType<TQuery, P>[]): this;
1524
+ isNull<P extends FilterableForInclude<TQuery, I>>(field: P): this;
1525
+ isNotNull<P extends FilterableForInclude<TQuery, I>>(field: P): this;
1526
+ arraySome<P extends ArrayFilterableFields<TQuery>>(field: P, value: ArrayItemType<TQuery, P>): this;
1527
+ arrayNone<P extends ArrayFilterableFields<TQuery>>(field: P, value: ArrayItemType<TQuery, P>): this;
1528
+ isEmpty<P extends ArrayFilterableFields<TQuery>>(field: P): this;
1529
+ isNotEmpty<P extends ArrayFilterableFields<TQuery>>(field: P): this;
1530
+ arrayEvery<P extends ArrayFilterableFields<TQuery>>(_field: P, _value: ArrayItemType<TQuery, P>): this;
1531
+ arrayContainsAll<P extends ArrayFilterableFields<TQuery>>(_field: P, _values: ArrayItemType<TQuery, P>[]): this;
1532
+ arrayLength<P extends ArrayFilterableFields<TQuery>>(_field: P, _op: "eq" | "ne" | "gt" | "gte" | "lt" | "lte", _value: number): this;
1533
+ nested<P extends FilterableForInclude<TQuery, I>>(field: P, callback: (q: FilterBuilder<TQuery, unknown>) => void): this;
1534
+ and(callback: (q: FilterBuilder<TQuery, unknown>) => void): this;
1535
+ or(callback: (q: FilterBuilder<TQuery, unknown>) => void): this;
1536
+ not(callback: (q: FilterBuilder<TQuery, unknown>) => void): this;
1537
+ raw(sql: string, params?: SQLQueryBindings[]): this;
1538
+ orderBy<P extends OrderableFields<TQuery>>(field: P, direction?: "ASC" | "DESC"): this;
1539
+ thenBy<P extends OrderableFields<TQuery>>(field: P, direction?: "ASC" | "DESC"): this;
1540
+ limit(n: number): this;
1541
+ offset(n: number): this;
1542
+ select<S extends SelectableKeys<TQuery>[]>(...fields: S): this;
1543
+ include<Inc extends SubTableKeys<TQuery>[]>(...relations: Inc): FilterBuilder<TQuery, TResult, Inc[number]>;
1544
+ distinct(): this;
1545
+ distinctOn<D extends DistinctableFields<TQuery>[]>(...fields: D): this;
1546
+ includeDeleted(): this;
1547
+ exec(): TResult;
1548
+ execAsync(): Promise<TResult>;
1549
+ execThrowable(): TResult;
1550
+ }
1551
+ declare class AggregateBuilder<TQuery extends TSchema6 & {
1552
+ properties: Record<string, TSchema6>;
1553
+ }> {
1554
+ private _executor;
1555
+ private _asyncExecutor?;
1556
+ private _aggregations;
1557
+ private _groupByFields;
1558
+ private _havingNodes;
1559
+ private _whereNodes;
1560
+ private _includeDeletedValue;
1561
+ constructor(_executor: (state: AggregateBuilderState) => Record<string, unknown>[], _asyncExecutor?: ((state: AggregateBuilderState) => Promise<Record<string, unknown>[]>) | undefined);
1562
+ sum(field: string, alias: string): this;
1563
+ count(field: string, alias: string): this;
1564
+ avg(field: string, alias: string): this;
1565
+ min(field: string, alias: string): this;
1566
+ max(field: string, alias: string): this;
1567
+ groupBy<G extends string[]>(...fields: G): this;
1568
+ having(callback: (q: FilterBuilder<TQuery, unknown>) => void): this;
1569
+ includeDeleted(): this;
1570
+ exec(): Record<string, unknown>[];
1571
+ execAsync(): Promise<Record<string, unknown>[]>;
1572
+ }
1573
+ import { TSchema as TSchema7 } from "typebox";
1574
+ declare function ftsTableName(tableName: string): string;
1575
+ declare function resolveFtsColumns(meta: TableMeta, fts: FTSConfig): string[];
1576
+ interface FtsSnippetSpec {
1577
+ field: string;
1578
+ open: string;
1579
+ close: string;
1580
+ ellipsis: string;
1581
+ tokens: number;
1582
+ }
1583
+ interface FtsHighlightSpec {
1584
+ field: string;
1585
+ open: string;
1586
+ close: string;
1587
+ }
1588
+ interface FtsSearchState {
1589
+ query: string;
1590
+ limit?: number;
1591
+ offset?: number;
1592
+ weightMap?: Record<string, number>;
1593
+ weights?: number[];
1594
+ snippets: FtsSnippetSpec[];
1595
+ highlights: FtsHighlightSpec[];
1596
+ includeDeleted: boolean;
1597
+ nodes: ConditionNode[];
1598
+ }
1599
+ type FtsResult<E> = E & {
1600
+ _score: number;
1601
+ _snippet: Record<string, string>;
1602
+ _highlight: Record<string, string>;
1603
+ };
1604
+ declare function buildFtsSearchSql(tableName: string, ftsColumns: string[], state: FtsSearchState, softDeleteColumn: string | undefined, meta: TableMeta): {
1605
+ sql: string;
1606
+ params: SQLQueryBindings[];
1607
+ snippetAliases: Array<{
1608
+ field: string;
1609
+ alias: string;
1610
+ }>;
1611
+ highlightAliases: Array<{
1612
+ field: string;
1613
+ alias: string;
1614
+ }>;
1615
+ };
1616
+ declare class FtsSearchBuilder<
1617
+ TQuery extends TSchema7 & {
1618
+ properties: Record<string, TSchema7>;
1619
+ },
1620
+ TEntity,
1621
+ FTS extends string
1622
+ > {
1623
+ private _exec;
1624
+ private _execAsync?;
1625
+ _state: FtsSearchState;
1626
+ constructor(query: string, _exec: (state: FtsSearchState) => FtsResult<TEntity>[], _execAsync?: ((state: FtsSearchState) => Promise<FtsResult<TEntity>[]>) | undefined);
1627
+ limit(n: number): this;
1628
+ offset(n: number): this;
1629
+ includeDeleted(): this;
1630
+ weight(field: FTS, w: number): this;
1631
+ weights(map: Partial<Record<FTS, number>>): this;
1632
+ snippet(field: FTS, opts?: {
1633
+ open?: string;
1634
+ close?: string;
1635
+ ellipsis?: string;
1636
+ tokens?: number;
1637
+ }): this;
1638
+ highlight(field: FTS, opts?: {
1639
+ open?: string;
1640
+ close?: string;
1641
+ }): this;
1642
+ where(cb: (q: FilterBuilder<TQuery, unknown>) => void): this;
1643
+ exec(): FtsResult<TEntity>[];
1644
+ execAsync(): Promise<FtsResult<TEntity>[]>;
1645
+ }
1241
1646
  interface BatchWriterOptions {
1242
1647
  maxBuffer?: number;
1243
1648
  flushIntervalMs?: number;
@@ -1253,7 +1658,7 @@ declare class BatchWriter<
1253
1658
  private readonly prepare;
1254
1659
  private readonly onFlush?;
1255
1660
  private timer?;
1256
- constructor(tableName: string, db: BunDatabase, opts: BatchWriterOptions, callbacks: {
1661
+ constructor(tableName: string, db: BunDatabase, opts: BatchWriterOptions | undefined, callbacks: {
1257
1662
  prepare: (row: TInput) => TRow;
1258
1663
  onFlush?: (rows: TRow[]) => void;
1259
1664
  });
@@ -1261,6 +1666,25 @@ declare class BatchWriter<
1261
1666
  flush(): void;
1262
1667
  close(): void;
1263
1668
  }
1669
+ declare class ReadScheduler {
1670
+ private workers;
1671
+ private workerStatus;
1672
+ private taskCounter;
1673
+ private readonly MAX_PENDING_TASKS;
1674
+ private readonly pendingTasks;
1675
+ private readonly overflowQueue;
1676
+ private overflowHead;
1677
+ private nextWorkerHint;
1678
+ private readonly columnCache;
1679
+ constructor(opts?: DatabaseOptions, workerCount?: number);
1680
+ private initWorkers;
1681
+ private dispatch;
1682
+ private dequeueOrIdle;
1683
+ exec<T = any>(sql: string, params?: any[]): Promise<T>;
1684
+ execWithCols<T extends Record<string, unknown> = Record<string, unknown>>(sql: string, params: any[], columns: string[]): Promise<T[]>;
1685
+ private enqueue;
1686
+ terminate(): void;
1687
+ }
1264
1688
  /**
1265
1689
  * Typed repository for a single table. Every entry in your `tables` config
1266
1690
  * becomes one of these on the ORM object, fully typed to its schema.
@@ -1283,15 +1707,16 @@ declare class BatchWriter<
1283
1707
  * ```
1284
1708
  */
1285
1709
  declare class Repository<
1286
- TWrite extends TSchema5 & {
1287
- properties: Record<string, TSchema5>;
1710
+ TWrite extends TSchema8 & {
1711
+ properties: Record<string, TSchema8>;
1288
1712
  },
1289
- TQuery extends TSchema5 & {
1290
- properties: Record<string, TSchema5>;
1713
+ TQuery extends TSchema8 & {
1714
+ properties: Record<string, TSchema8>;
1291
1715
  },
1292
1716
  PK extends ScalarKeys<TWrite>,
1293
1717
  Mat = never,
1294
- TS = {}
1718
+ TS = {},
1719
+ FTS extends string = never
1295
1720
  > {
1296
1721
  readonly tableName: string;
1297
1722
  /** table metadata - columns, sub-tables, indexes */
@@ -1312,16 +1737,29 @@ declare class Repository<
1312
1737
  private readonly descriptor;
1313
1738
  private _entityProto;
1314
1739
  private readonly _timestampNames;
1740
+ private readonly _hasTimestamps;
1741
+ private readonly _hasEviction;
1315
1742
  private _materialize?;
1316
1743
  private _materializeMany?;
1317
1744
  private _events?;
1318
1745
  private _executor;
1319
1746
  private readonly _codecs;
1747
+ private readonly _insertColsSql;
1748
+ private readonly _insertPlaceholders;
1749
+ private readonly _readScheduler?;
1750
+ private readonly _allColumnNames;
1751
+ private readonly _onDeleteBehavior;
1752
+ private readonly _ftsEnabled;
1753
+ private readonly _ftsTableName;
1754
+ private readonly _ftsColumns;
1755
+ private readonly _ftsColumnSet;
1756
+ private readonly _ftsInsertDirectSql;
1757
+ private readonly _ftsDeleteDirectSql;
1320
1758
  /** @internal */
1321
1759
  setEventBus(bus: EventBus): void;
1322
1760
  /** @internal */
1323
1761
  setMetricsHook(hook?: (meta: QueryMetrics) => void): void;
1324
- constructor(tableName: string, config: TableConfig<TWrite, PK & string, TimestampConfig, GeneratedColumnConfig | undefined>, db: BunDatabase);
1762
+ constructor(tableName: string, config: TableConfig<TWrite, PK & string, TimestampConfig, GeneratedColumnConfig | undefined, FTSConfig | undefined>, db: BunDatabase, readScheduler?: ReadScheduler, onDeleteBehavior?: "native" | "foxdb" | "none");
1325
1763
  /** Ensure PK is selected when include is requested */
1326
1764
  private _ensureSelectPk;
1327
1765
  /**
@@ -1331,8 +1769,10 @@ declare class Repository<
1331
1769
  private _fetchRows;
1332
1770
  /** Inject materializers after ORM two-pass init */
1333
1771
  setMaterializer(single: (record: Record<string, unknown>) => Record<string, unknown>, many: (records: Record<string, unknown>[]) => Record<string, unknown>[]): void;
1334
- /** Wrap raw data in an entity object */
1772
+ /** Wrap raw data in an entity object (with sub-table fields) */
1335
1773
  private _wrap;
1774
+ /** Wrap raw data in an entity object (without sub-table fields) */
1775
+ private _wrapNoSubs;
1336
1776
  /** Narrow a parsed schema value to a plain record for dynamic property access */
1337
1777
  private _record;
1338
1778
  /** Validate that a value is a valid SQLite scalar for use as a primary key */
@@ -1380,6 +1820,7 @@ declare class Repository<
1380
1820
  * ```
1381
1821
  */
1382
1822
  insert(data: InsertData<TWrite>): Entity<Infer<TQuery>, Mat, TS>;
1823
+ private _insertRow;
1383
1824
  /**
1384
1825
  * Insert many records in a single transaction.
1385
1826
  *
@@ -1454,139 +1895,142 @@ declare class Repository<
1454
1895
  findById(id: Infer<TQuery>[PK]): Entity<Infer<TQuery>, Mat, TS> | null;
1455
1896
  /** Internal findById without event emission - used by update() */
1456
1897
  private _findByIdRaw;
1898
+ /** Internal raw row fetch without hydration - used by update() */
1899
+ private _findFlatRow;
1457
1900
  /**
1458
1901
  * Find many records matching the given filters.
1902
+ * Legacy object-based API - use `findMany()` chain API for new code.
1459
1903
  *
1460
1904
  * @group Reading
1461
1905
  *
1462
1906
  * @example
1463
1907
  * ```ts
1464
- * const adults = orm.users.findMany({
1908
+ * const adults = orm.users.O_findMany({
1465
1909
  * where: { age: { gte: 18 } },
1466
1910
  * orderBy: { column: "name", direction: "ASC" },
1467
1911
  * limit: 10,
1468
1912
  * });
1469
- *
1470
- * // Include sub-tables
1471
- * const orders = orm.orders.findMany({ include: ["lineItems"] });
1472
1913
  * ```
1473
1914
  */
1474
- findMany<
1915
+ O_findMany<
1475
1916
  const S extends readonly SelectableKeys<TQuery>[],
1476
1917
  const I extends readonly SubTableKeys<TQuery>[]
1477
1918
  >(opts: FindOptions<TQuery> & {
1478
1919
  select: S;
1479
1920
  include: I;
1480
- }): (SelectShape<TQuery, S> & TS & { [K in I[number]] : SubTableItem<TQuery, K>[] })[];
1481
- findMany<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1921
+ }): (SelectShape<TQuery, S> & { [K in I[number]] : SubTableItem<TQuery, K>[] })[];
1922
+ O_findMany<const I extends readonly SubTableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1923
+ include: I;
1924
+ }): (Entity<Infer<TQuery>, Mat, TS> & { [K in I[number]] : SubTableItem<TQuery, K>[] })[];
1925
+ O_findMany<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1482
1926
  select: S;
1483
- }): (SelectShape<TQuery, S> & TS)[];
1484
- findMany(opts?: FindOptions<TQuery>): Entity<Infer<TQuery>, Mat, TS>[];
1927
+ }): (SelectShape<TQuery, S>)[];
1928
+ O_findMany(opts?: FindOptions<TQuery>): Entity<Infer<TQuery>, Mat, TS>[];
1485
1929
  /**
1486
1930
  * Find many with total count - useful for pagination.
1931
+ * Legacy object-based API - use `findPage()` chain API for new code.
1487
1932
  *
1488
1933
  * @group Reading
1489
1934
  *
1490
1935
  * @example
1491
1936
  * ```ts
1492
- * const page = orm.users.findPage({
1937
+ * const page = orm.users.O_findPage({
1493
1938
  * where: { status: { eq: "active" } },
1494
1939
  * limit: 10,
1495
1940
  * offset: 0,
1496
1941
  * });
1497
- * // page.data - the records
1498
- * // page.total - total matching records
1499
- * // page.limit, page.offset - what you passed in
1500
1942
  * ```
1501
1943
  */
1502
- findPage<
1944
+ O_findPage<
1503
1945
  const S extends readonly SelectableKeys<TQuery>[],
1504
1946
  const I extends readonly SubTableKeys<TQuery>[]
1505
1947
  >(opts: FindOptions<TQuery> & {
1506
1948
  select: S;
1507
1949
  include: I;
1508
- }): PageResult<SelectShape<TQuery, S> & TS & { [K in I[number]] : SubTableItem<TQuery, K>[] }>;
1509
- findPage<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1950
+ }): PageResult<SelectShape<TQuery, S> & { [K in I[number]] : SubTableItem<TQuery, K>[] }>;
1951
+ O_findPage<const I extends readonly SubTableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1952
+ include: I;
1953
+ }): PageResult<Entity<Infer<TQuery>, Mat, TS> & { [K in I[number]] : SubTableItem<TQuery, K>[] }>;
1954
+ O_findPage<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1510
1955
  select: S;
1511
- }): PageResult<SelectShape<TQuery, S> & TS>;
1512
- findPage(opts?: FindOptions<TQuery>): PageResult<Entity<Infer<TQuery>, Mat, TS>>;
1956
+ }): PageResult<SelectShape<TQuery, S>>;
1957
+ O_findPage(opts?: FindOptions<TQuery>): PageResult<Entity<Infer<TQuery>, Mat, TS>>;
1513
1958
  /**
1514
1959
  * Cursor-based pagination (seek method). Avoids OFFSET degradation on
1515
1960
  * large tables by using a boundary value from the previous page.
1961
+ * Legacy object-based API - use `findCursorPage()` chain API for new code.
1516
1962
  *
1517
1963
  * @group Reading
1518
1964
  *
1519
1965
  * @example
1520
1966
  * ```ts
1521
- * const page = orm.orders.findCursorPage({
1522
- * orderBy: { column: "DocumentDate", direction: "DESC" },
1523
- * limit: 25,
1524
- * });
1525
- *
1526
- * const next = orm.orders.findCursorPage({
1967
+ * const page = orm.orders.O_findCursorPage({
1527
1968
  * orderBy: { column: "DocumentDate", direction: "DESC" },
1528
- * cursor: page.nextCursor!,
1529
1969
  * limit: 25,
1530
1970
  * });
1531
1971
  * ```
1532
1972
  */
1533
- findCursorPage(opts: {
1973
+ O_findCursorPage(opts: {
1534
1974
  where?: WhereClause<TQuery>;
1535
1975
  orderBy: OrderByClause<TQuery>;
1536
1976
  cursor?: CursorInput;
1537
1977
  limit?: number;
1538
1978
  }): CursorPageResult<Entity<Infer<TQuery>, Mat, TS>>;
1539
1979
  /**
1540
- * Find a single record matching the given filters. Equivalent to `findMany`
1541
- * with `limit: 1`, but returns the entity directly (or `null`).
1980
+ * Find a single record matching the given filters.
1981
+ * Legacy object-based API - use `findOne()` chain API for new code.
1542
1982
  *
1543
1983
  * @group Reading
1544
1984
  *
1545
1985
  * @example
1546
1986
  * ```ts
1547
- * const admin = orm.users.findOne({
1987
+ * const admin = orm.users.O_findOne({
1548
1988
  * where: { role: { eq: "admin" } },
1549
1989
  * });
1550
1990
  * ```
1551
1991
  */
1552
- findOne<
1992
+ O_findOne<
1553
1993
  const S extends readonly SelectableKeys<TQuery>[],
1554
1994
  const I extends readonly SubTableKeys<TQuery>[]
1555
1995
  >(opts: FindOptions<TQuery> & {
1556
1996
  select: S;
1557
1997
  include: I;
1558
- }): (SelectShape<TQuery, S> & TS & { [K in I[number]] : SubTableItem<TQuery, K>[] }) | null;
1559
- findOne<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1998
+ }): (SelectShape<TQuery, S> & { [K in I[number]] : SubTableItem<TQuery, K>[] }) | null;
1999
+ O_findOne<const I extends readonly SubTableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
2000
+ include: I;
2001
+ }): (Entity<Infer<TQuery>, Mat, TS> & { [K in I[number]] : SubTableItem<TQuery, K>[] }) | null;
2002
+ O_findOne<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1560
2003
  select: S;
1561
- }): (SelectShape<TQuery, S> & TS) | null;
1562
- findOne(opts?: FindOptions<TQuery>): Entity<Infer<TQuery>, Mat, TS> | null;
2004
+ }): (SelectShape<TQuery, S>) | null;
2005
+ O_findOne(opts?: FindOptions<TQuery>): Entity<Infer<TQuery>, Mat, TS> | null;
1563
2006
  /**
1564
2007
  * Iterate over records matching the given filters, yielding one row at a time.
1565
- * Sub-tables are hydrated in windows to keep memory stable.
2008
+ * Legacy object-based API - use `iterate()` chain API for new code.
1566
2009
  *
1567
2010
  * @group Reading
1568
2011
  *
1569
2012
  * @example
1570
2013
  * ```ts
1571
- * for (const user of orm.users.iterate({ where: { active: { eq: true } } })) {
2014
+ * for (const user of orm.users.O_iterate({ where: { active: { eq: true } } })) {
1572
2015
  * console.log(user.name);
1573
2016
  * }
1574
2017
  * ```
1575
2018
  */
1576
- iterate<
2019
+ O_iterate<
1577
2020
  const S extends readonly SelectableKeys<TQuery>[],
1578
2021
  const I extends readonly SubTableKeys<TQuery>[]
1579
2022
  >(opts: FindOptions<TQuery> & {
1580
2023
  select: S;
1581
2024
  include: I;
1582
- }): Generator<SelectShape<TQuery, S> & TS & { [K in I[number]] : SubTableItem<TQuery, K>[] }>;
1583
- iterate<const I extends readonly SubTableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
2025
+ }): Generator<SelectShape<TQuery, S> & { [K in I[number]] : SubTableItem<TQuery, K>[] }>;
2026
+ O_iterate<const I extends readonly SubTableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1584
2027
  include: I;
1585
2028
  }): Generator<Entity<Infer<TQuery>, Mat, TS> & { [K in I[number]] : SubTableItem<TQuery, K>[] }>;
1586
- iterate<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
2029
+ O_iterate<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
1587
2030
  select: S;
1588
- }): Generator<SelectShape<TQuery, S> & TS>;
1589
- iterate(opts?: FindOptions<TQuery>): Generator<Entity<Infer<TQuery>, Mat, TS>>;
2031
+ }): Generator<SelectShape<TQuery, S>>;
2032
+ O_iterate(opts?: FindOptions<TQuery>): Generator<Entity<Infer<TQuery>, Mat, TS>>;
2033
+ private _iterateImpl;
1590
2034
  private _hydrateWindow;
1591
2035
  /**
1592
2036
  * Find many with resolved relations (n+1 safe). If you have cross-table
@@ -1605,35 +2049,32 @@ declare class Repository<
1605
2049
  findManyMaterialized(opts?: FindOptions<TQuery>): Entity<Infer<TQuery>, Mat, TS>[];
1606
2050
  /**
1607
2051
  * Count records matching the given filters.
2052
+ * Legacy object-based API - use `count()` chain API for new code.
1608
2053
  *
1609
2054
  * @group Reading
1610
2055
  *
1611
2056
  * @example
1612
2057
  * ```ts
1613
- * const total = orm.users.count();
1614
- * const adults = orm.users.count({ age: { gte: 18 } });
2058
+ * const total = orm.users.O_count();
2059
+ * const adults = orm.users.O_count({ age: { gte: 18 } });
1615
2060
  * ```
1616
2061
  */
1617
- count(where?: WhereClause<TQuery>): number;
2062
+ O_count(where?: WhereClause<TQuery>): number;
1618
2063
  /**
1619
2064
  * Run aggregate queries (sum, count, avg, min, max) with optional
1620
2065
  * grouping and filtering.
2066
+ * Legacy object-based API - use `aggregate()` chain API for new code.
1621
2067
  *
1622
2068
  * @group Reading
1623
2069
  *
1624
2070
  * @example
1625
2071
  * ```ts
1626
- * orm.orders.aggregate({
2072
+ * orm.orders.O_aggregate({
1627
2073
  * aggregations: { total: { sum: "amount" } },
1628
2074
  * });
1629
- *
1630
- * orm.orders.aggregate({
1631
- * groupBy: ["status"],
1632
- * aggregations: { count: { count: "*" }, avgAmount: { avg: "amount" } },
1633
- * });
1634
2075
  * ```
1635
2076
  */
1636
- aggregate<
2077
+ O_aggregate<
1637
2078
  const A extends Record<string, AggregationOp<TQuery>>,
1638
2079
  const G extends readonly (ScalarKeys<TQuery> | ScalarJsonPath<TQuery>)[] | undefined = undefined
1639
2080
  >(opts: AggregateOptions<TQuery, A> & {
@@ -1642,12 +2083,13 @@ declare class Repository<
1642
2083
  /**
1643
2084
  * Run window function queries (rowNumber, rank, denseRank, lead, lag)
1644
2085
  * with partitioning and ordering.
2086
+ * Legacy object-based API - use `windowQuery()` chain API for new code.
1645
2087
  *
1646
2088
  * @group Reading
1647
2089
  *
1648
2090
  * @example
1649
2091
  * ```ts
1650
- * orm.orders.windowQuery({
2092
+ * orm.orders.O_windowQuery({
1651
2093
  * partitionBy: ["Status__Group"],
1652
2094
  * orderBy: [{ column: "DocumentDate", direction: "DESC" }],
1653
2095
  * select: {
@@ -1659,10 +2101,200 @@ declare class Repository<
1659
2101
  * });
1660
2102
  * ```
1661
2103
  */
1662
- windowQuery<const W extends Record<string, WindowFunction<TQuery>>>(opts: WindowQueryOptions<TQuery> & {
2104
+ O_windowQuery<const W extends Record<string, WindowFunction<TQuery>>>(opts: WindowQueryOptions<TQuery> & {
1663
2105
  select: W;
1664
2106
  }): WindowResult<TQuery, W>;
1665
2107
  /**
2108
+ * Async variant of O_findMany - executes on the worker thread pool.
2109
+ */
2110
+ O_findManyAsync<
2111
+ const S extends readonly SelectableKeys<TQuery>[],
2112
+ const I extends readonly SubTableKeys<TQuery>[]
2113
+ >(opts: FindOptions<TQuery> & {
2114
+ select: S;
2115
+ include: I;
2116
+ }): Promise<(SelectShape<TQuery, S> & { [K in I[number]] : SubTableItem<TQuery, K>[] })[]>;
2117
+ O_findManyAsync<const I extends readonly SubTableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
2118
+ include: I;
2119
+ }): Promise<(Entity<Infer<TQuery>, Mat, TS> & { [K in I[number]] : SubTableItem<TQuery, K>[] })[]>;
2120
+ O_findManyAsync<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
2121
+ select: S;
2122
+ }): Promise<(SelectShape<TQuery, S>)[]>;
2123
+ O_findManyAsync(opts?: FindOptions<TQuery>): Promise<Entity<Infer<TQuery>, Mat, TS>[]>;
2124
+ /**
2125
+ * Async variant of O_findOne - executes on the worker thread pool.
2126
+ */
2127
+ O_findOneAsync<
2128
+ const S extends readonly SelectableKeys<TQuery>[],
2129
+ const I extends readonly SubTableKeys<TQuery>[]
2130
+ >(opts: FindOptions<TQuery> & {
2131
+ select: S;
2132
+ include: I;
2133
+ }): Promise<(SelectShape<TQuery, S> & { [K in I[number]] : SubTableItem<TQuery, K>[] }) | null>;
2134
+ O_findOneAsync<const I extends readonly SubTableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
2135
+ include: I;
2136
+ }): Promise<(Entity<Infer<TQuery>, Mat, TS> & { [K in I[number]] : SubTableItem<TQuery, K>[] }) | null>;
2137
+ O_findOneAsync<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
2138
+ select: S;
2139
+ }): Promise<(SelectShape<TQuery, S>) | null>;
2140
+ O_findOneAsync(opts?: FindOptions<TQuery>): Promise<Entity<Infer<TQuery>, Mat, TS> | null>;
2141
+ /**
2142
+ * Async variant of O_findPage - executes on the worker thread pool.
2143
+ */
2144
+ O_findPageAsync<
2145
+ const S extends readonly SelectableKeys<TQuery>[],
2146
+ const I extends readonly SubTableKeys<TQuery>[]
2147
+ >(opts: FindOptions<TQuery> & {
2148
+ select: S;
2149
+ include: I;
2150
+ }): Promise<PageResult<SelectShape<TQuery, S> & { [K in I[number]] : SubTableItem<TQuery, K>[] }>>;
2151
+ O_findPageAsync<const I extends readonly SubTableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
2152
+ include: I;
2153
+ }): Promise<PageResult<Entity<Infer<TQuery>, Mat, TS> & { [K in I[number]] : SubTableItem<TQuery, K>[] }>>;
2154
+ O_findPageAsync<const S extends readonly SelectableKeys<TQuery>[]>(opts: FindOptions<TQuery> & {
2155
+ select: S;
2156
+ }): Promise<PageResult<SelectShape<TQuery, S>>>;
2157
+ O_findPageAsync(opts?: FindOptions<TQuery>): Promise<PageResult<Entity<Infer<TQuery>, Mat, TS>>>;
2158
+ /**
2159
+ * Async variant of O_findCursorPage - executes on the worker thread pool.
2160
+ */
2161
+ O_findCursorPageAsync(opts: {
2162
+ where?: WhereClause<TQuery>;
2163
+ orderBy: OrderByClause<TQuery>;
2164
+ cursor?: CursorInput;
2165
+ limit?: number;
2166
+ }): Promise<CursorPageResult<Entity<Infer<TQuery>, Mat, TS>>>;
2167
+ /**
2168
+ * Async variant of O_count - executes on the worker thread pool.
2169
+ */
2170
+ O_countAsync(where?: WhereClause<TQuery>): Promise<number>;
2171
+ /**
2172
+ * Async variant of O_aggregate - executes on the worker thread pool.
2173
+ */
2174
+ O_aggregateAsync<
2175
+ const A extends Record<string, AggregationOp<TQuery>>,
2176
+ const G extends readonly (ScalarKeys<TQuery> | ScalarJsonPath<TQuery>)[] | undefined = undefined
2177
+ >(opts: AggregateOptions<TQuery, A> & {
2178
+ groupBy?: G;
2179
+ }): Promise<AggregateResult<TQuery, A, G>>;
2180
+ /**
2181
+ * Async variant of O_windowQuery - executes on the worker thread pool.
2182
+ */
2183
+ O_windowQueryAsync<const W extends Record<string, WindowFunction<TQuery>>>(opts: WindowQueryOptions<TQuery> & {
2184
+ select: W;
2185
+ }): Promise<WindowResult<TQuery, W>>;
2186
+ /**
2187
+ * Async variant of findById - executes on the worker thread pool.
2188
+ */
2189
+ findByIdAsync(id: Infer<TQuery>[PK]): Promise<Entity<Infer<TQuery>, Mat, TS> | null>;
2190
+ /**
2191
+ * Async variant of findManyMaterialized - executes on the worker thread pool.
2192
+ */
2193
+ findManyMaterializedAsync(opts?: FindOptions<TQuery>): Promise<Entity<Infer<TQuery>, Mat, TS>[]>;
2194
+ /**
2195
+ * Async variant of raw - executes on the worker thread pool.
2196
+ */
2197
+ rawAsync<R = DBRow>(sql: string, ...params: DBValue[]): Promise<R[]>;
2198
+ /**
2199
+ * Start a chain filter query that returns many records.
2200
+ *
2201
+ * @group Reading - Chain API
2202
+ *
2203
+ * @example
2204
+ * ```ts
2205
+ * const adults = orm.users
2206
+ * .findMany()
2207
+ * .greaterThanOrEqual("age", 18)
2208
+ * .equals("active", true)
2209
+ * .orderBy("createdAt", "DESC")
2210
+ * .limit(10)
2211
+ * .exec();
2212
+ * ```
2213
+ */
2214
+ findMany(): FilterBuilder<TQuery, Entity<Infer<TQuery>, Mat, TS>[]>;
2215
+ /**
2216
+ * Start a chain filter query that returns a single record.
2217
+ *
2218
+ * @group Reading - Chain API
2219
+ *
2220
+ * @example
2221
+ * ```ts
2222
+ * const admin = orm.users
2223
+ * .findOne()
2224
+ * .equals("role", "admin")
2225
+ * .exec();
2226
+ * ```
2227
+ */
2228
+ findOne(): FilterBuilder<TQuery, Entity<Infer<TQuery>, Mat, TS> | null>;
2229
+ /**
2230
+ * Start a chain count query.
2231
+ *
2232
+ * @group Reading - Chain API
2233
+ *
2234
+ * @example
2235
+ * ```ts
2236
+ * const total = orm.users
2237
+ * .count()
2238
+ * .equals("active", true)
2239
+ * .exec();
2240
+ * ```
2241
+ */
2242
+ count(): FilterBuilder<TQuery, number>;
2243
+ /**
2244
+ * Start a chain paginated query.
2245
+ *
2246
+ * @group Reading - Chain API
2247
+ *
2248
+ * @example
2249
+ * ```ts
2250
+ * const page = orm.users
2251
+ * .findPage()
2252
+ * .equals("active", true)
2253
+ * .limit(10)
2254
+ * .offset(0)
2255
+ * .exec();
2256
+ * ```
2257
+ */
2258
+ findPage(): FilterBuilder<TQuery, PageResult<Entity<Infer<TQuery>, Mat, TS>>>;
2259
+ /**
2260
+ * Start a chain cursor-paginated query.
2261
+ *
2262
+ * @group Reading - Chain API
2263
+ *
2264
+ * @example
2265
+ * ```ts
2266
+ * const page = orm.orders
2267
+ * .findCursorPage()
2268
+ * .orderBy("id", "ASC")
2269
+ * .limit(25)
2270
+ * .exec();
2271
+ * ```
2272
+ */
2273
+ findCursorPage(): FilterBuilder<TQuery, CursorPageResult<Entity<Infer<TQuery>, Mat, TS>>>;
2274
+ /**
2275
+ * Start a chain aggregate query.
2276
+ *
2277
+ * @group Reading - Chain API
2278
+ *
2279
+ * @example
2280
+ * ```ts
2281
+ * const totals = orm.orders
2282
+ * .aggregate()
2283
+ * .sum("amount", "totalRevenue")
2284
+ * .count("*", "orderCount")
2285
+ * .groupBy("status")
2286
+ * .exec();
2287
+ * ```
2288
+ */
2289
+ aggregate(): AggregateBuilder<TQuery>;
2290
+ /**
2291
+ * Full-text search (FTS5). Present only on tables with `fts` enabled.
2292
+ * @group Reading - Chain API
2293
+ */
2294
+ search(query: string): FtsSearchBuilder<TQuery, Entity<Infer<TQuery>, Mat, TS>, FTS>;
2295
+ /** Convenience async full-text search. Present only on tables with `fts` enabled. */
2296
+ searchAsync(query: string): Promise<FtsResult<Entity<Infer<TQuery>, Mat, TS>>[]>;
2297
+ /**
1666
2298
  * Update a record - must include the primary key. Returns the updated
1667
2299
  * entity, or `null` if no record matched.
1668
2300
  *
@@ -1733,6 +2365,13 @@ declare class Repository<
1733
2365
  * ```
1734
2366
  */
1735
2367
  drop(): void;
2368
+ private _ftsIndexByPk;
2369
+ private _ftsDeleteByPk;
2370
+ private _ftsIndexByRowid;
2371
+ private _ftsDeleteByRowid;
2372
+ private _patchTouchesFts;
2373
+ private _ftsBindInsert;
2374
+ private _ftsBindDelete;
1736
2375
  private _hydrateOne;
1737
2376
  /**
1738
2377
  * Run raw SQL - escape hatch for queries the ORM doesn't support directly.
@@ -1748,7 +2387,7 @@ declare class Repository<
1748
2387
  */
1749
2388
  raw<R = DBRow>(sql: string, ...params: DBValue[]): R[];
1750
2389
  }
1751
- declare class RelationBuilder<Tables extends Record<string, TableDescriptor<any, any, any, any>>> {
2390
+ declare class RelationBuilder<Tables extends Record<string, TableDescriptor<any, any, any, any, any>>> {
1752
2391
  private readonly tables;
1753
2392
  private readonly relations;
1754
2393
  constructor(tables: Tables);
@@ -1778,13 +2417,13 @@ declare class RelationBuilder<Tables extends Record<string, TableDescriptor<any,
1778
2417
  build(): TypedRelation[];
1779
2418
  }
1780
2419
  /** @category Relations */
1781
- declare function createRelationBuilder<T extends Record<string, TableDescriptor<any, any, any, any>>>(tables: T): RelationBuilder<T>;
1782
- import { Static as Static2 } from "typebox";
1783
- declare const SchemaHashSchema: unknown;
1784
- declare const SchemaJSONSchema: unknown;
1785
- declare const TablesSchema: unknown;
1786
- declare const RelationsSchema: unknown;
1787
- declare const VersionSchema: unknown;
2420
+ declare function createRelationBuilder<T extends Record<string, TableDescriptor<any, any, any, any, any>>>(tables: T): RelationBuilder<T>;
2421
+ import { Static as Static2, TSchema as TSchema9 } from "typebox";
2422
+ declare const SchemaHashSchema: TSchema9;
2423
+ declare const SchemaJSONSchema: TSchema9;
2424
+ declare const TablesSchema: TSchema9;
2425
+ declare const RelationsSchema: TSchema9;
2426
+ declare const VersionSchema: TSchema9;
1788
2427
  type SchemaHash = Static2<typeof SchemaHashSchema>;
1789
2428
  type SchemaJSON = Static2<typeof SchemaJSONSchema>;
1790
2429
  type TablesList = Static2<typeof TablesSchema>;
@@ -1826,7 +2465,7 @@ declare class MetaStore {
1826
2465
  * @category Lifecycle
1827
2466
  */
1828
2467
  interface ORMContext<
1829
- T extends Record<string, TableDescriptor<any, any, any, any>> = Record<string, TableDescriptor<any, any, any, any>>,
2468
+ T extends Record<string, TableDescriptor<any, any, any, any, any>> = Record<string, TableDescriptor<any, any, any, any, any>>,
1830
2469
  Rels extends readonly TypedRelation[] = readonly TypedRelation[]
1831
2470
  > {
1832
2471
  orm: foxdb<T, Rels>;
@@ -1844,7 +2483,7 @@ interface ORMContext<
1844
2483
  * @category Lifecycle
1845
2484
  */
1846
2485
  type LifecycleHook<
1847
- T extends Record<string, TableDescriptor<any, any, any, any>> = Record<string, TableDescriptor<any, any, any, any>>,
2486
+ T extends Record<string, TableDescriptor<any, any, any, any, any>> = Record<string, TableDescriptor<any, any, any, any, any>>,
1848
2487
  Rels extends readonly TypedRelation[] = readonly TypedRelation[]
1849
2488
  > = (ctx: ORMContext<T, Rels>) => void | Promise<void>;
1850
2489
  /**
@@ -1852,7 +2491,7 @@ type LifecycleHook<
1852
2491
  * @category Lifecycle
1853
2492
  */
1854
2493
  declare class LifecycleManager<
1855
- T extends Record<string, TableDescriptor<any, any, any, any>> = Record<string, TableDescriptor<any, any, any, any>>,
2494
+ T extends Record<string, TableDescriptor<any, any, any, any, any>> = Record<string, TableDescriptor<any, any, any, any, any>>,
1856
2495
  Rels extends readonly TypedRelation[] = readonly TypedRelation[]
1857
2496
  > {
1858
2497
  private startHooks;
@@ -1862,17 +2501,17 @@ declare class LifecycleManager<
1862
2501
  private _ready;
1863
2502
  private _shutdown;
1864
2503
  /** true after runReady completes */
1865
- get isReady();
2504
+ get isReady(): boolean;
1866
2505
  /** true after runShutdown completes */
1867
- get isShutdown();
2506
+ get isShutdown(): boolean;
1868
2507
  /** register a startup hook */
1869
- onStart(hook: LifecycleHook<T, Rels>);
2508
+ onStart(hook: LifecycleHook<T, Rels>): void;
1870
2509
  /** register a ready hook */
1871
- onReady(hook: LifecycleHook<T, Rels>);
2510
+ onReady(hook: LifecycleHook<T, Rels>): void;
1872
2511
  /** register a shutdown hook */
1873
- onShutdown(hook: LifecycleHook<T, Rels>);
2512
+ onShutdown(hook: LifecycleHook<T, Rels>): void;
1874
2513
  /** register an exit hook */
1875
- onExit(hook: LifecycleHook<T, Rels>);
2514
+ onExit(hook: LifecycleHook<T, Rels>): void;
1876
2515
  /** @internal */
1877
2516
  runStart(ctx: ORMContext<T, Rels>): void;
1878
2517
  /** @internal */
@@ -1897,6 +2536,15 @@ interface CreateORMBaseOptions {
1897
2536
  vacuumIntervalMs?: number;
1898
2537
  /** disable fsync during large initial loads */
1899
2538
  bulkLoadMode?: boolean;
2539
+ /** number of worker threads for async read queries (enables *Async methods) */
2540
+ asyncReaderPool?: number;
2541
+ /**
2542
+ * How sub-table foreign key deletions are handled.
2543
+ * - `"native"` (default): SQLite ON DELETE CASCADE - FK verification on INSERT.
2544
+ * - `"foxdb"`: No FK in DDL, foxdb handles cascading in application code - faster INSERTs.
2545
+ * - `"none"`: No FK, no cascade - sub-table rows become orphaned on parent delete.
2546
+ */
2547
+ onDeleteBehavior?: "native" | "foxdb" | "none";
1900
2548
  }
1901
2549
  /**
1902
2550
  * Options passed to `createORM`.
@@ -1927,7 +2575,7 @@ interface CreateORMBaseOptions {
1927
2575
  * ```
1928
2576
  */
1929
2577
  interface CreateORMOptions<
1930
- T extends Record<string, TableDescriptor<any, any, any, any>> = Record<string, TableDescriptor<any, any, any, any>>,
2578
+ T extends Record<string, TableDescriptor<any, any, any, any, any>> = Record<string, TableDescriptor<any, any, any, any, any>>,
1931
2579
  Rels extends readonly TypedRelation[] = readonly TypedRelation[]
1932
2580
  > extends CreateORMBaseOptions {
1933
2581
  /** table schemas */
@@ -1978,7 +2626,7 @@ interface CreateORMOptions<
1978
2626
  *
1979
2627
  * Every key in your `tables` config becomes a fully typed **Repository**
1980
2628
  * with CRUD methods. The type definition below is a mapped type that
1981
- * transforms your schema config into the actual runtime API — TypeDoc
2629
+ * transforms your schema config into the actual runtime API - TypeDoc
1982
2630
  * cannot expand it, so see the example for how it works in practice.
1983
2631
  *
1984
2632
  * @see {@link Repository} for the full method reference
@@ -1993,7 +2641,7 @@ interface CreateORMOptions<
1993
2641
  * },
1994
2642
  * });
1995
2643
  *
1996
- * // ─── Every table key is a Repository ───
2644
+ * // --- Every table key is a Repository ---
1997
2645
  *
1998
2646
  * // Insert
1999
2647
  * orm.users.insert({ id: "u1", name: "alice" });
@@ -2012,7 +2660,7 @@ interface CreateORMOptions<
2012
2660
  * orm.users.deleteById("u1");
2013
2661
  * orm.users.deleteWhere({ status: { eq: "banned" } });
2014
2662
  *
2015
- * // ─── Framework methods (prefixed with _) ───
2663
+ * // --- Framework methods (prefixed with _) ---
2016
2664
  *
2017
2665
  * orm._transaction(() => {
2018
2666
  * orm.users.insert({ id: "t1", name: "txn" });
@@ -2023,11 +2671,11 @@ interface CreateORMOptions<
2023
2671
  * ```
2024
2672
  */
2025
2673
  type foxdb<
2026
- Tables extends Record<string, TableDescriptor<any, any, any, any>>,
2674
+ Tables extends Record<string, TableDescriptor<any, any, any, any, any>>,
2027
2675
  Rels extends readonly TypedRelation[] = readonly TypedRelation[]
2028
- > = { [K in keyof Tables] : Tables[K] extends TableDescriptor<infer TWrite extends TSchema6 & {
2029
- properties: Record<string, TSchema6>;
2030
- }, infer PKName extends string, infer Timestamps, infer G extends GeneratedColumnConfig | undefined> ? Repository<TWrite, QuerySchema<TWrite, G>, PKName extends ScalarKeys<TWrite> ? PKName : never, Materialized<TWrite, Tables, Rels, K & string>, TimestampShape<Timestamps>> : never } & {
2676
+ > = { [K in keyof Tables] : Tables[K] extends TableDescriptor<infer TWrite extends TSchema10 & {
2677
+ properties: Record<string, TSchema10>;
2678
+ }, infer PKName extends string, infer Timestamps, infer G extends GeneratedColumnConfig | undefined, infer F> ? FTSEnabled<F> extends true ? Repository<TWrite, QuerySchema<TWrite, G>, PKName extends ScalarKeys<TWrite> ? PKName : never, Materialized<TWrite, Tables, Rels, K & string>, TimestampShape<Timestamps>, FTSFields<TWrite, F> & string> : Omit<Repository<TWrite, QuerySchema<TWrite, G>, PKName extends ScalarKeys<TWrite> ? PKName : never, Materialized<TWrite, Tables, Rels, K & string>, TimestampShape<Timestamps>, never>, "search" | "searchAsync"> : never } & {
2031
2679
  /** run a transaction */
2032
2680
  _transaction<R>(fn: () => R): R;
2033
2681
  /** close the database */
@@ -2051,7 +2699,7 @@ type foxdb<
2051
2699
  };
2052
2700
  /** create a typed orm instance backed by sqlite */
2053
2701
  declare function createORM<
2054
- const T extends Record<string, TableDescriptor<any, any, any, any>>,
2702
+ const T extends Record<string, TableDescriptor<any, any, any, any, any>>,
2055
2703
  const Rels extends readonly TypedRelation[] = readonly TypedRelation[]
2056
2704
  >(opts: CreateORMOptions<T, Rels>): foxdb<T, Rels>;
2057
2705
  declare function migrate(opts: MigrateOptions): Promise<void>;
@@ -2161,4 +2809,4 @@ interface DesiredTable {
2161
2809
  declare function computeDiff(desired: DesiredTable[], actual: InspectorTable[]): SchemaDiff;
2162
2810
  /** @category Migration */
2163
2811
  declare function applySync(diff: SchemaDiff, db: BunDatabase, policy: SyncPolicy, desired: DesiredTable[]): void;
2164
- export { withTrace, table, resolveTimestampNames, raise, migrate, introspectTable, inspectSchema, inspectAllTables, foxdb, createRelationBuilder, createORM, createMigration, computeDiff, buildCreateTableSQL, applySync, WhereClause, UpsertOptions, UpdateData, UnlinkPolicy, TypedRelation, TraceEntry, TimestampShape, TimestampConfig2 as TimestampNamesConfig, TableOperation, TableMeta, TableEventPayload, TableEventOperation, TableDescriptor, TableConfigShape, TableConfig, TScalarSchema, SyncPolicy, SubTableScalarPath, SubTableMeta, SubTableKeys, SubTableConfig, SubMergeType, SubMergeNames, SubMerge, SqliteType, SchemaJSONSchema, SchemaJSON, SchemaDiff, SchemaChange, ScalarProperties, ScalarPath, ScalarMergeType, ScalarMergeNames, ScalarMerge, ScalarKeys, ScalarFilter, Repository, RelationsConfig, RelationEntry, RelationBuilder, QueryMetricsHook, QueryMetrics, PageResult, OrderByClause, ORMEvents, ORMErrorContext, ORMError, ORMContext, Migration, MigrateOptions, MetaStore, Materialized, Listener, LifecycleManager, LifecycleHook, LifecycleEventMap, InspectorTable, InspectorIndex, InspectorColumn, InsertData, Infer, IndexDefinition, GeneratedColumnConfig, FindOptions, EventBus, ErrorPolicy2 as ErrorPolicy, Entity, DesiredTable, DatabaseOptions, DEFAULT_TIMESTAMP_NAMES, CreateORMOptions, CreateORMBaseOptions, ColumnRefs, ColumnRef, ColumnMeta, BunStatement, BunDatabase, BroadOperation, BatchWriterOptions, BatchWriter, ArrayOfObjectProperties, AggregationOp, AggregateOptions };
2812
+ export { AggregateBuilder, AggregateBuilderState, AggregateOptions, AggregationOp, ArrayFilterableFields, ArrayItemType, ArrayOfObjectProperties, BatchWriter, BatchWriterOptions, BroadOperation, BunDatabase, BunStatement, ColumnMeta, ColumnRef, ColumnRefs, ConditionNode, CreateORMBaseOptions, CreateORMOptions, DEFAULT_TIMESTAMP_NAMES, DatabaseOptions, DesiredTable, DistinctableFields, Entity, ErrorPolicy2 as ErrorPolicy, EventBus, FTSConfig, FTSEnabled, FTSFields, FieldType, FilterBuilder, FilterableFields, FindOptions, FtsHighlightSpec, FtsResult, FtsSearchBuilder, FtsSearchState, FtsSnippetSpec, GeneratedColumnConfig, IndexDefinition, Infer, InsertData, InspectorColumn, InspectorIndex, InspectorTable, InternalBuilderState, LifecycleEventMap, LifecycleHook, LifecycleManager, Listener, Materialized, MetaStore, MigrateOptions, Migration, ORMContext, ORMError, ORMErrorContext, ORMEvents, OrderByClause, OrderableFields, PageResult, QueryMetrics, QueryMetricsHook, RelationBuilder, RelationEntry, RelationsConfig, Repository, ScalarFilter, ScalarKeys, ScalarMerge, ScalarMergeNames, ScalarMergeType, ScalarPath, ScalarProperties, SchemaChange, SchemaDiff, SchemaJSON, SchemaJSONSchema, SqliteType, SubMerge, SubMergeNames, SubMergeType, SubTableConfig, SubTableKeys, SubTableMeta, SubTableScalarPath, SyncPolicy, TScalarSchema, TableConfig, TableConfigShape, TableDescriptor, TableEventOperation, TableEventPayload, TableMeta, TableOperation, TimestampConfig2 as TimestampNamesConfig, TimestampShape, TraceEntry, TypedRelation, UnlinkPolicy, UpdateData, UpsertOptions, WhereClause, applySync, buildCreateTableSQL, buildFtsSearchSql, buildWhereFromNodes, computeDiff, createMigration, createORM, createRelationBuilder, foxdb, ftsTableName, inspectAllTables, inspectSchema, introspectTable, migrate, raise, resolveFtsColumns, resolveTimestampNames, table, withTrace };