edinburgh 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +322 -262
  2. package/build/src/datapack.d.ts +9 -9
  3. package/build/src/datapack.js +9 -9
  4. package/build/src/edinburgh.d.ts +18 -7
  5. package/build/src/edinburgh.js +30 -51
  6. package/build/src/edinburgh.js.map +1 -1
  7. package/build/src/indexes.d.ts +85 -205
  8. package/build/src/indexes.js +150 -503
  9. package/build/src/indexes.js.map +1 -1
  10. package/build/src/migrate.js +8 -10
  11. package/build/src/migrate.js.map +1 -1
  12. package/build/src/models.d.ts +152 -107
  13. package/build/src/models.js +433 -144
  14. package/build/src/models.js.map +1 -1
  15. package/build/src/types.d.ts +30 -48
  16. package/build/src/types.js +25 -24
  17. package/build/src/types.js.map +1 -1
  18. package/build/src/utils.d.ts +4 -4
  19. package/build/src/utils.js +4 -4
  20. package/package.json +1 -1
  21. package/skill/AnyModelClass.md +7 -0
  22. package/skill/FindOptions.md +37 -0
  23. package/skill/Lifecycle Hooks.md +24 -0
  24. package/skill/{Model_delete.md → Lifecycle Hooks_delete.md } +1 -1
  25. package/skill/{Model_getPrimaryKeyHash.md → Lifecycle Hooks_getPrimaryKeyHash.md } +1 -1
  26. package/skill/{Model_isValid.md → Lifecycle Hooks_isValid.md } +1 -1
  27. package/skill/Lifecycle Hooks_migrate.md +26 -0
  28. package/skill/{Model_preCommit.md → Lifecycle Hooks_preCommit.md } +2 -2
  29. package/skill/{Model_preventPersist.md → Lifecycle Hooks_preventPersist.md } +1 -1
  30. package/skill/{Model_validate.md → Lifecycle Hooks_validate.md } +2 -2
  31. package/skill/ModelBase.md +7 -0
  32. package/skill/ModelClass.md +8 -0
  33. package/skill/SKILL.md +180 -132
  34. package/skill/Schema Evolution.md +19 -0
  35. package/skill/TypeWrapper_containsNull.md +11 -0
  36. package/skill/TypeWrapper_deserialize.md +9 -0
  37. package/skill/TypeWrapper_getError.md +11 -0
  38. package/skill/TypeWrapper_serialize.md +10 -0
  39. package/skill/TypeWrapper_serializeType.md +9 -0
  40. package/skill/array.md +2 -2
  41. package/skill/defineModel.md +3 -2
  42. package/skill/deleteEverything.md +8 -0
  43. package/skill/field.md +3 -3
  44. package/skill/link.md +3 -3
  45. package/skill/literal.md +1 -1
  46. package/skill/opt.md +1 -1
  47. package/skill/or.md +1 -1
  48. package/skill/record.md +1 -1
  49. package/skill/set.md +2 -2
  50. package/skill/setOnSaveCallback.md +2 -2
  51. package/skill/transact.md +1 -1
  52. package/src/datapack.ts +9 -9
  53. package/src/edinburgh.ts +43 -52
  54. package/src/indexes.ts +251 -599
  55. package/src/migrate.ts +9 -10
  56. package/src/models.ts +528 -231
  57. package/src/types.ts +36 -34
  58. package/src/utils.ts +4 -4
  59. package/skill/BaseIndex.md +0 -16
  60. package/skill/BaseIndex_batchProcess.md +0 -10
  61. package/skill/BaseIndex_find.md +0 -7
  62. package/skill/BaseIndex_find_2.md +0 -7
  63. package/skill/BaseIndex_find_3.md +0 -7
  64. package/skill/BaseIndex_find_4.md +0 -7
  65. package/skill/Model.md +0 -20
  66. package/skill/Model_batchProcess.md +0 -8
  67. package/skill/Model_migrate.md +0 -32
  68. package/skill/Model_replaceInto.md +0 -16
  69. package/skill/NonPrimaryIndex.md +0 -10
  70. package/skill/SecondaryIndex.md +0 -9
  71. package/skill/UniqueIndex.md +0 -9
  72. package/skill/dump.md +0 -8
@@ -1,15 +1,28 @@
1
1
  import DataPack from "./datapack.js";
2
- import { Model, Transaction } from "./models.js";
2
+ import { type Transaction } from "./edinburgh.js";
3
3
  import { TypeWrapper } from "./types.js";
4
- type IndexArgTypes<M extends typeof Model<any>, F extends readonly (keyof InstanceType<M> & string)[]> = {
5
- [I in keyof F]: InstanceType<M>[F[I]];
4
+ type IndexItem = {
5
+ _setLoadedField(fieldName: string, value: any): void;
6
+ _restoreLazyFields?(): void;
7
+ };
8
+ type PrimaryKeyItem = IndexItem & {
9
+ _oldValues: Record<string, any> | undefined | null | false;
10
+ _primaryKey: Uint8Array | undefined;
11
+ _txn: Transaction;
12
+ _setPrimaryKey(key: Uint8Array, hash?: number): void;
13
+ };
14
+ type FieldTypes = ReadonlyMap<string, TypeWrapper<any>>;
15
+ type LoadPrimary<ITEM> = (txn: Transaction, primaryKey: Uint8Array, loadNow: boolean | Uint8Array) => ITEM | undefined;
16
+ type QueueInitialization = () => void;
17
+ type IndexArgTypes<ITEM, F extends readonly (keyof ITEM & string)[]> = {
18
+ [I in keyof F]: ITEM[F[I]];
6
19
  };
7
20
  /** Cached information about a specific version of a primary index's value format. */
8
21
  export interface VersionInfo {
9
22
  migrateHash: number;
10
23
  /** Non-key field names → TypeWrappers for deserialization of this version's data. */
11
24
  nonKeyFields: Map<string, TypeWrapper<any>>;
12
- /** Set of serialized secondary index signatures that existed in this version. */
25
+ /** Set of serialized secondary index signatures that existed in this version's data. */
13
26
  secondaryKeys: Set<string>;
14
27
  }
15
28
  /**
@@ -17,18 +30,29 @@ export interface VersionInfo {
17
30
  * Handles common iteration logic for both primary and unique indexes.
18
31
  * Extends built-in Iterator to provide map/filter/reduce/toArray/etc.
19
32
  */
20
- export declare class IndexRangeIterator<M extends typeof Model> extends Iterator<InstanceType<M>> {
33
+ export declare class IndexRangeIterator<ITEM> extends Iterator<ITEM> {
21
34
  private txn;
22
35
  private iteratorId;
23
- private indexId;
24
36
  private parentIndex;
25
- constructor(txn: Transaction, iteratorId: number, indexId: number, parentIndex: BaseIndex<M, any>);
37
+ constructor(txn: Transaction, iteratorId: number, parentIndex: BaseIndex<ITEM, any>);
26
38
  [Symbol.iterator](): this;
27
- next(): IteratorResult<InstanceType<M>>;
39
+ next(): IteratorResult<ITEM>;
28
40
  count(): number;
29
- fetch(): InstanceType<M> | undefined;
41
+ fetch(): ITEM | undefined;
30
42
  }
31
43
  type ArrayOrOnlyItem<ARG_TYPES extends readonly any[]> = ARG_TYPES extends readonly [infer A] ? (A | Partial<ARG_TYPES>) : Partial<ARG_TYPES>;
44
+ /**
45
+ * Range-query options accepted by `find()`, `findBy()`, `batchProcess()`, and `batchProcessBy()`.
46
+ *
47
+ * Supports exact-match lookups via `is`, inclusive bounds via `from` / `to`,
48
+ * exclusive bounds via `after` / `before`, and reverse scans.
49
+ *
50
+ * For single-field indexes, values can be passed directly. For composite indexes,
51
+ * pass tuples or partial tuples for prefix matching.
52
+ *
53
+ * @template ARG_TYPES - Tuple of index argument types.
54
+ * @template FETCH - Optional fetch mode used by overloads that return one row.
55
+ */
32
56
  export type FindOptions<ARG_TYPES extends readonly any[], FETCH extends 'first' | 'single' | undefined = undefined> = (({
33
57
  is: ArrayOrOnlyItem<ARG_TYPES>;
34
58
  } | (({
@@ -50,235 +74,91 @@ export type FindOptions<ARG_TYPES extends readonly any[], FETCH extends 'first'
50
74
  * Base class for database indexes for efficient lookups on model fields.
51
75
  *
52
76
  * Indexes enable fast queries on specific field combinations and enforce uniqueness constraints.
53
- *
54
- * @template M - The model class this index belongs to.
55
- * @template F - The field names that make up this index.
56
77
  */
57
- export declare abstract class BaseIndex<M extends typeof Model, const F extends readonly (keyof InstanceType<M> & string)[], ARGS extends readonly any[] = IndexArgTypes<M, F>> {
58
- _fieldNames: F;
59
- _MyModel: M;
60
- _fieldTypes: Map<keyof InstanceType<M> & string, TypeWrapper<any>>;
61
- _fieldCount: number;
78
+ export declare abstract class BaseIndex<ITEM, const F extends readonly (keyof ITEM & string)[], ARGS extends readonly any[] = IndexArgTypes<ITEM, F>> {
79
+ tableName: string;
80
+ _indexFields: Map<F[number], TypeWrapper<any>>;
62
81
  _computeFn?: (data: any) => any[];
63
- /**
64
- * Create a new index.
65
- * @param MyModel - The model class this index belongs to.
66
- * @param _fieldNames - Array of field names that make up this index.
67
- */
68
- constructor(MyModel: M, _fieldNames: F);
69
- _delayedInit(): Promise<void>;
70
82
  _indexId?: number;
71
- /** Human-readable signature for version tracking, e.g. "secondary category:string" */
72
83
  _signature?: string;
73
- /**
74
- * Serialize array of key values to a (index-id prefixed) Bytes instance that can be used as a key.
75
- * @param args - Field values to serialize (can be partial for range queries).
76
- * @returns A Bytes instance containing the index id and serialized key parts.
77
- * @internal
78
- */
84
+ constructor(tableName: string, fieldNames: F);
85
+ _initializeIndex(fields: FieldTypes, reset?: boolean, primaryFieldTypes?: FieldTypes): Promise<void>;
79
86
  _argsToKeyBytes(args: [], allowPartial: boolean): DataPack;
80
87
  _argsToKeyBytes(args: Partial<ARGS>, allowPartial: boolean): DataPack;
88
+ abstract _pairToInstance(txn: Transaction, keyBuffer: ArrayBuffer, valueBuffer: ArrayBuffer): ITEM;
89
+ abstract _getTypeName(): string;
90
+ _retrieveIndexId(fields: FieldTypes, primaryFieldTypes?: FieldTypes): Promise<void>;
91
+ _computeKeyBounds(opts: FindOptions<ARGS>): [DataPack | undefined, DataPack | undefined] | null;
81
92
  /**
82
- * Extract model from iterator entry - implemented differently by each index type.
83
- * @param keyBuffer - Key bytes (including index id).
84
- * @param valueBuffer - Value bytes from the entry.
85
- * @returns Model instance or undefined.
86
- * @internal
87
- */
88
- abstract _pairToInstance(txn: Transaction, keyBuffer: ArrayBuffer, valueBuffer: ArrayBuffer): InstanceType<M>;
89
- /**
90
- * Retrieve (or create) a stable index ID from the DB, with retry on transaction races.
91
- * Sets `this._indexId` on success.
92
- */
93
- _retrieveIndexId(): Promise<void>;
94
- /**
95
- * Find model instances using flexible range query options.
96
- *
97
- * Supports exact matches, inclusive/exclusive range queries, and reverse iteration.
98
- * For single-field indexes, you can pass values directly or in arrays.
99
- * For multi-field indexes, pass arrays or partial arrays for prefix matching.
93
+ * Find rows using exact-match or range-query options.
100
94
  *
101
- * @param opts - Query options object
102
- * @param opts.is - Exact match (sets both `from` and `to` to same value)
103
- * @param opts.from - Range start (inclusive)
104
- * @param opts.after - Range start (exclusive)
105
- * @param opts.to - Range end (inclusive)
106
- * @param opts.before - Range end (exclusive)
107
- * @param opts.reverse - Whether to iterate in reverse order
108
- * @returns An iterable of model instances matching the query
95
+ * Supports exact matches, inclusive and exclusive bounds, open-ended ranges,
96
+ * and reverse iteration. For single-field indexes, values can be passed
97
+ * directly. For composite indexes, pass tuples or partial tuples.
109
98
  *
110
99
  * @example
111
100
  * ```typescript
112
- * // Exact match
113
- * for (const user of User.byEmail.find({is: "john@example.com"})) {
114
- * console.log(user.name);
115
- * }
116
- *
117
- * // Range query (inclusive)
118
- * for (const user of User.byEmail.find({from: "a@", to: "m@"})) {
119
- * console.log(user.email);
120
- * }
121
- *
122
- * // Range query (exclusive)
123
- * for (const user of User.byEmail.find({after: "a@", before: "m@"})) {
124
- * console.log(user.email);
125
- * }
126
- *
127
- * // Open-ended ranges
128
- * for (const user of User.byEmail.find({from: "m@"})) { // m@ and later
129
- * console.log(user.email);
130
- * }
131
- *
132
- * for (const user of User.byEmail.find({to: "m@"})) { // up to and including m@
133
- * console.log(user.email);
134
- * }
135
- *
136
- * // Reverse iteration
137
- * for (const user of User.byEmail.find({reverse: true})) {
138
- * console.log(user.email); // Z to A order
139
- * }
140
- *
141
- * // Multi-field index prefix matching
142
- * for (const item of CompositeModel.find({from: ["electronics", "phones"]})) {
143
- * console.log(item.name); // All electronics/phones items
144
- * }
145
- *
146
- * // For single-field indexes, you can use the value directly
147
- * for (const user of User.byEmail.find({is: "john@example.com"})) {
148
- * console.log(user.name);
149
- * }
101
+ * const exact = User.find({ is: "user-123", fetch: "first" });
102
+ * const email = [...User.findBy("email", { from: "a@test.com", to: "m@test.com" })];
103
+ * const reverse = [...Product.findBy("category", { is: "electronics", reverse: true })];
150
104
  * ```
151
105
  */
152
- _computeKeyBounds(opts: FindOptions<ARGS>): [DataPack | undefined, DataPack | undefined] | null;
153
- find(opts?: FindOptions<ARGS, 'first'>): InstanceType<M> | undefined;
154
- find(opts: FindOptions<ARGS, 'single'>): InstanceType<M>;
155
- find(opts?: FindOptions<ARGS>): IndexRangeIterator<M>;
106
+ find(opts: FindOptions<ARGS, 'first'>): ITEM | undefined;
107
+ find(opts: FindOptions<ARGS, 'single'>): ITEM;
108
+ find(opts?: FindOptions<ARGS>): IndexRangeIterator<ITEM>;
156
109
  /**
157
- * Process all matching rows in batched transactions.
110
+ * Process matching rows in batched transactions.
158
111
  *
159
- * Uses the same query options as {@link find}. The batch is committed and a new
160
- * transaction started once either `limitSeconds` or `limitRows` is exceeded.
112
+ * Uses the same range options as {@link find}, plus optional row and time
113
+ * limits that control when the current transaction is committed and a new one starts.
161
114
  *
162
- * @param opts - Query options (same as `find()`), plus:
163
- * @param opts.limitSeconds - Max seconds per transaction batch (default: 1)
164
- * @param opts.limitRows - Max rows per transaction batch (default: 4096)
165
- * @param callback - Called for each matching row within a transaction
115
+ * @param opts Query options plus batch limits.
116
+ * @param callback Called for each matching row inside a transaction.
166
117
  */
167
118
  batchProcess(opts: (FindOptions<ARGS> & {
168
119
  limitSeconds?: number;
169
120
  limitRows?: number;
170
- }) | undefined, callback: (row: InstanceType<M>) => void | Promise<void>): Promise<void>;
171
- abstract _getTypeName(): string;
121
+ }) | undefined, callback: (row: ITEM) => void | Promise<void>): Promise<void>;
172
122
  toString(): string;
173
123
  }
174
- /**
175
- * Primary index that stores the actual model data.
176
- *
177
- * @template M - The model class this index belongs to.
178
- * @template F - The field names that make up this index.
179
- */
180
- export declare class PrimaryIndex<M extends typeof Model, const F extends readonly (keyof InstanceType<M> & string)[]> extends BaseIndex<M, F, IndexArgTypes<M, F>> {
181
- _nonKeyFields: (keyof InstanceType<M> & string)[];
182
- _lazyDescriptors: Record<string | symbol | number, PropertyDescriptor>;
183
- _resetDescriptors: Record<string | symbol | number, PropertyDescriptor>;
184
- _freezePrimaryKeyDescriptors: Record<string | symbol | number, PropertyDescriptor>;
185
- /** Current version number for this primary index's value format. */
186
- _currentVersion: number;
187
- /** Hash of the current migrate() function source, or 0 if none. */
188
- _currentMigrateHash: number;
189
- /** Cached version info for old versions (loaded on demand). */
190
- _versions: Map<number, VersionInfo>;
191
- constructor(MyModel: M, fieldNames: F);
192
- _delayedInit(): Promise<void>;
193
- /** Serialize the current version fingerprint as a DataPack object. */
194
- _serializeVersionValue(): Uint8Array;
195
- /** Look up or create the current version number for this primary index. */
196
- _initVersioning(): Promise<void>;
197
- /**
198
- * Get a model instance by primary key values.
199
- * @param args - The primary key values.
200
- * @returns The model instance if found, undefined otherwise.
201
- *
202
- * @example
203
- * ```typescript
204
- * const user = User.get("john_doe");
205
- * ```
206
- */
207
- get(...args: IndexArgTypes<M, F>): InstanceType<M> | undefined;
208
- /**
209
- * Does the same as as `get()`, but will delay loading the instance from disk until the first
210
- * property access. In case it turns out the instance doesn't exist, an error will be thrown
211
- * at that time.
212
- * @param args Primary key field values. (Or a single Uint8Array containing the key.)
213
- * @returns The (lazily loaded) model instance.
214
- */
215
- getLazy(...args: IndexArgTypes<M, F>): InstanceType<M>;
216
- _get(txn: Transaction, args: IndexArgTypes<M, F> | Uint8Array, loadNow: false | Uint8Array): InstanceType<M>;
217
- _get(txn: Transaction, args: IndexArgTypes<M, F> | Uint8Array, loadNow: true): InstanceType<M> | undefined;
218
- /**
219
- * Serialize primary key bytes from field values: indexId + typed field values.
220
- */
221
- _serializeKey(data: Record<string, any>): DataPack;
222
- _lazyNow(model: InstanceType<M>): void;
223
- _setNonKeyValues(model: InstanceType<M>, valueArray: Uint8Array): void;
224
- /** Load a version's info from DB, caching the result. */
225
- _loadVersionInfo(txnId: number, version: number): VersionInfo;
226
- /** Deserialize and migrate a row from an old version. */
227
- _migrateFromVersion(model: InstanceType<M>, version: number, valuePack: DataPack): void;
228
- _keyToArray(key: Uint8Array): IndexArgTypes<M, F>;
229
- _pairToInstance(txn: Transaction, keyBuffer: ArrayBuffer, valueBuffer: ArrayBuffer): InstanceType<M>;
124
+ export declare abstract class PrimaryKey<ITEM extends PrimaryKeyItem, const F extends readonly (keyof ITEM & string)[], ARGS extends readonly any[] = IndexArgTypes<ITEM, F>> extends BaseIndex<ITEM, F, ARGS> {
230
125
  _getTypeName(): string;
231
- _write(txn: Transaction, primaryKey: Uint8Array, data: Record<string, any>): void;
232
- _delete(txn: Transaction, primaryKey: Uint8Array, _data: Record<string, any>): void;
126
+ abstract _serializeValue(data: Record<string, any>): Uint8Array;
127
+ _versionInfoKey(version: number): Uint8Array;
128
+ _ensureVersionEntry(currentValueBytes: Uint8Array): Promise<{
129
+ version: number;
130
+ created: boolean;
131
+ }>;
132
+ _serializePK(data: Record<string, any>): DataPack;
133
+ _pkToArray(key: Uint8Array): ARGS;
134
+ _writePK(txn: Transaction, primaryKey: Uint8Array, data: Record<string, any>): void;
135
+ _deletePK(txn: Transaction, primaryKey: Uint8Array, _data: Record<string, any>): void;
233
136
  }
234
- /**
235
- * Abstract base for all non-primary indexes (unique and secondary).
236
- * Provides shared key serialization, write/delete/update logic.
237
- */
238
- export declare abstract class NonPrimaryIndex<M extends typeof Model, const F extends readonly (keyof InstanceType<M> & string)[], ARGS extends readonly any[] = IndexArgTypes<M, F>> extends BaseIndex<M, F, ARGS> {
137
+ export declare abstract class NonPrimaryIndex<ITEM extends IndexItem, const F extends readonly (keyof ITEM & string)[], ARGS extends readonly any[] = IndexArgTypes<ITEM, F>> extends BaseIndex<ITEM, F, ARGS> {
138
+ protected _loadPrimary: LoadPrimary<ITEM>;
239
139
  _resetIndexFieldDescriptors: Record<string | symbol | number, PropertyDescriptor>;
240
- constructor(MyModel: M, fieldsOrFn: F | ((data: any) => any[]));
241
- _delayedInit(): Promise<void>;
242
- /**
243
- * Build DataPack key prefixes (indexId + field/computed values). Returns [] to skip indexing.
244
- * SecondaryIndex appends the primary key to each pack before converting to Uint8Array.
245
- */
140
+ constructor(tableName: string, fieldsOrFn: F | ((data: any) => any[]), _loadPrimary: LoadPrimary<ITEM>, queueInitialization: QueueInitialization);
141
+ _initializeIndex(fields: FieldTypes, reset?: boolean, primaryFieldTypes?: FieldTypes): Promise<void>;
246
142
  _buildKeyPacks(data: Record<string, any>): DataPack[];
247
- /** Serialize all index keys. Default: key = indexId + fields. */
248
143
  _serializeKeys(primaryKey: Uint8Array, data: Record<string, any>): Uint8Array[];
249
- /** Write a single pre-serialized key — subclasses define value and uniqueness check. */
250
144
  abstract _writeKey(txn: Transaction, key: Uint8Array, primaryKey: Uint8Array): void;
251
- _write(txn: Transaction, primaryKey: Uint8Array, model: InstanceType<M>): void;
252
- _delete(txn: Transaction, primaryKey: Uint8Array, model: InstanceType<M>): void;
253
- /**
254
- * Granular update: diff old vs new keys and only insert/delete what changed.
255
- * For non-computed indexes, uses a fast path that checks which fields changed.
256
- */
257
- _update(txn: Transaction, primaryKey: Uint8Array, newData: InstanceType<M>, oldData: Record<string, any>): number;
145
+ _write(txn: Transaction, primaryKey: Uint8Array, model: ITEM): void;
146
+ _delete(txn: Transaction, primaryKey: Uint8Array, model: ITEM): void;
147
+ _update(txn: Transaction, primaryKey: Uint8Array, newData: ITEM, oldData: Record<string, any>): number;
258
148
  }
259
- /**
260
- * Unique index that stores references to the primary key.
261
- */
262
- export declare class UniqueIndex<M extends typeof Model, const F extends readonly (keyof InstanceType<M> & string)[], ARGS extends readonly any[] = IndexArgTypes<M, F>> extends NonPrimaryIndex<M, F, ARGS> {
263
- get(...args: ARGS): InstanceType<M> | undefined;
264
- _writeKey(txn: Transaction, key: Uint8Array, primaryKey: Uint8Array): void;
265
- _pairToInstance(txn: Transaction, keyBuffer: ArrayBuffer, valueBuffer: ArrayBuffer): InstanceType<M>;
149
+ export declare class UniqueIndex<ITEM extends IndexItem, const F extends readonly (keyof ITEM & string)[], ARGS extends readonly any[] = IndexArgTypes<ITEM, F>> extends NonPrimaryIndex<ITEM, F, ARGS> {
150
+ constructor(tableName: string, fieldsOrFn: F | ((data: any) => any[]), loadPrimary: LoadPrimary<ITEM>, queueInitialization: QueueInitialization);
266
151
  _getTypeName(): string;
152
+ getPK(...args: ARGS): ITEM | undefined;
153
+ _writeKey(txn: Transaction, key: Uint8Array, primaryKey: Uint8Array): void;
154
+ _pairToInstance(txn: Transaction, keyBuffer: ArrayBuffer, valueBuffer: ArrayBuffer): ITEM;
267
155
  }
268
- /**
269
- * Secondary index for non-unique lookups.
270
- */
271
- export declare class SecondaryIndex<M extends typeof Model, const F extends readonly (keyof InstanceType<M> & string)[], ARGS extends readonly any[] = IndexArgTypes<M, F>> extends NonPrimaryIndex<M, F, ARGS> {
272
- _pairToInstance(txn: Transaction, keyBuffer: ArrayBuffer, _valueBuffer: ArrayBuffer): InstanceType<M>;
156
+ export declare class SecondaryIndex<ITEM extends IndexItem, const F extends readonly (keyof ITEM & string)[], ARGS extends readonly any[] = IndexArgTypes<ITEM, F>> extends NonPrimaryIndex<ITEM, F, ARGS> {
157
+ constructor(tableName: string, fieldsOrFn: F | ((data: any) => any[]), loadPrimary: LoadPrimary<ITEM>, queueInitialization: QueueInitialization);
158
+ _getTypeName(): string;
159
+ _pairToInstance(txn: Transaction, keyBuffer: ArrayBuffer, _valueBuffer: ArrayBuffer): ITEM;
273
160
  _serializeKeys(primaryKey: Uint8Array, data: Record<string, any>): Uint8Array[];
274
161
  _writeKey(txn: Transaction, key: Uint8Array, _primaryKey: Uint8Array): void;
275
- _getTypeName(): string;
276
162
  }
277
- /**
278
- * Dump database contents for debugging.
279
- *
280
- * Prints all indexes and their data to the console for inspection.
281
- * This is primarily useful for development and debugging purposes.
282
- */
283
163
  export declare function dump(): void;
284
164
  export {};