tinybase 6.1.0-beta.1 → 6.1.0-beta.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.
Files changed (108) hide show
  1. package/@types/common/index.d.ts +4 -4
  2. package/@types/common/with-schemas/index.d.ts +4 -4
  3. package/@types/mergeable-store/index.d.ts +45 -20
  4. package/@types/mergeable-store/with-schemas/index.d.ts +49 -21
  5. package/@types/persisters/index.d.ts +1 -1
  6. package/@types/persisters/with-schemas/index.d.ts +1 -1
  7. package/index.js +19 -11
  8. package/indexes/index.js +15 -3
  9. package/indexes/with-schemas/index.js +15 -3
  10. package/mergeable-store/index.js +4 -8
  11. package/mergeable-store/with-schemas/index.js +4 -8
  12. package/min/index.js +1 -1
  13. package/min/index.js.gz +0 -0
  14. package/min/indexes/index.js +1 -1
  15. package/min/indexes/index.js.gz +0 -0
  16. package/min/indexes/with-schemas/index.js +1 -1
  17. package/min/indexes/with-schemas/index.js.gz +0 -0
  18. package/min/mergeable-store/index.js +1 -1
  19. package/min/mergeable-store/index.js.gz +0 -0
  20. package/min/mergeable-store/with-schemas/index.js +1 -1
  21. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  22. package/min/with-schemas/index.js +1 -1
  23. package/min/with-schemas/index.js.gz +0 -0
  24. package/package.json +9 -9
  25. package/readme.md +2 -2
  26. package/with-schemas/index.js +19 -11
  27. package/@types/_internal/queries/index.d.cts +0 -0
  28. package/@types/_internal/queries/with-schemas/index.d.cts +0 -22
  29. package/@types/_internal/store/index.d.cts +0 -3
  30. package/@types/_internal/store/with-schemas/index.d.cts +0 -106
  31. package/@types/_internal/ui-react/index.d.cts +0 -0
  32. package/@types/_internal/ui-react/with-schemas/index.d.cts +0 -1130
  33. package/@types/checkpoints/index.d.cts +0 -1059
  34. package/@types/checkpoints/with-schemas/index.d.cts +0 -1151
  35. package/@types/common/index.d.cts +0 -158
  36. package/@types/common/with-schemas/index.d.cts +0 -158
  37. package/@types/index.d.cts +0 -17
  38. package/@types/indexes/index.d.cts +0 -1064
  39. package/@types/indexes/with-schemas/index.d.cts +0 -1210
  40. package/@types/mergeable-store/index.d.cts +0 -1139
  41. package/@types/mergeable-store/with-schemas/index.d.cts +0 -1628
  42. package/@types/metrics/index.d.cts +0 -917
  43. package/@types/metrics/with-schemas/index.d.cts +0 -1004
  44. package/@types/persisters/index.d.cts +0 -1877
  45. package/@types/persisters/persister-automerge/index.d.cts +0 -165
  46. package/@types/persisters/persister-automerge/with-schemas/index.d.cts +0 -180
  47. package/@types/persisters/persister-browser/index.d.cts +0 -185
  48. package/@types/persisters/persister-browser/with-schemas/index.d.cts +0 -208
  49. package/@types/persisters/persister-cr-sqlite-wasm/index.d.cts +0 -159
  50. package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.cts +0 -178
  51. package/@types/persisters/persister-durable-object-storage/index.d.cts +0 -122
  52. package/@types/persisters/persister-durable-object-storage/with-schemas/index.d.cts +0 -136
  53. package/@types/persisters/persister-electric-sql/index.d.cts +0 -185
  54. package/@types/persisters/persister-electric-sql/with-schemas/index.d.cts +0 -204
  55. package/@types/persisters/persister-expo-sqlite/index.d.cts +0 -186
  56. package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.cts +0 -205
  57. package/@types/persisters/persister-file/index.d.cts +0 -94
  58. package/@types/persisters/persister-file/with-schemas/index.d.cts +0 -107
  59. package/@types/persisters/persister-indexed-db/index.d.cts +0 -120
  60. package/@types/persisters/persister-indexed-db/with-schemas/index.d.cts +0 -135
  61. package/@types/persisters/persister-libsql/index.d.cts +0 -158
  62. package/@types/persisters/persister-libsql/with-schemas/index.d.cts +0 -177
  63. package/@types/persisters/persister-partykit-client/index.d.cts +0 -195
  64. package/@types/persisters/persister-partykit-client/with-schemas/index.d.cts +0 -210
  65. package/@types/persisters/persister-partykit-server/index.d.cts +0 -650
  66. package/@types/persisters/persister-partykit-server/with-schemas/index.d.cts +0 -695
  67. package/@types/persisters/persister-pglite/index.d.cts +0 -177
  68. package/@types/persisters/persister-pglite/with-schemas/index.d.cts +0 -196
  69. package/@types/persisters/persister-postgres/index.d.cts +0 -166
  70. package/@types/persisters/persister-postgres/with-schemas/index.d.cts +0 -185
  71. package/@types/persisters/persister-powersync/index.d.cts +0 -174
  72. package/@types/persisters/persister-powersync/with-schemas/index.d.cts +0 -193
  73. package/@types/persisters/persister-remote/index.d.cts +0 -117
  74. package/@types/persisters/persister-remote/with-schemas/index.d.cts +0 -133
  75. package/@types/persisters/persister-sqlite-wasm/index.d.cts +0 -175
  76. package/@types/persisters/persister-sqlite-wasm/with-schemas/index.d.cts +0 -195
  77. package/@types/persisters/persister-sqlite3/index.d.cts +0 -176
  78. package/@types/persisters/persister-sqlite3/with-schemas/index.d.cts +0 -195
  79. package/@types/persisters/persister-yjs/index.d.cts +0 -161
  80. package/@types/persisters/persister-yjs/with-schemas/index.d.cts +0 -176
  81. package/@types/persisters/with-schemas/index.d.cts +0 -2054
  82. package/@types/queries/index.d.cts +0 -3695
  83. package/@types/queries/with-schemas/index.d.cts +0 -4016
  84. package/@types/relationships/index.d.cts +0 -1320
  85. package/@types/relationships/with-schemas/index.d.cts +0 -1474
  86. package/@types/store/index.d.cts +0 -7598
  87. package/@types/store/with-schemas/index.d.cts +0 -9278
  88. package/@types/synchronizers/index.d.cts +0 -485
  89. package/@types/synchronizers/synchronizer-broadcast-channel/index.d.cts +0 -121
  90. package/@types/synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.cts +0 -137
  91. package/@types/synchronizers/synchronizer-local/index.d.cts +0 -95
  92. package/@types/synchronizers/synchronizer-local/with-schemas/index.d.cts +0 -114
  93. package/@types/synchronizers/synchronizer-ws-client/index.d.cts +0 -160
  94. package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.cts +0 -179
  95. package/@types/synchronizers/synchronizer-ws-server/index.d.cts +0 -736
  96. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +0 -765
  97. package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.cts +0 -311
  98. package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.cts +0 -349
  99. package/@types/synchronizers/synchronizer-ws-server-simple/index.d.cts +0 -144
  100. package/@types/synchronizers/synchronizer-ws-server-simple/with-schemas/index.d.cts +0 -144
  101. package/@types/synchronizers/with-schemas/index.d.cts +0 -503
  102. package/@types/ui-react/index.d.cts +0 -16640
  103. package/@types/ui-react/with-schemas/index.d.cts +0 -17281
  104. package/@types/ui-react-dom/index.d.cts +0 -1862
  105. package/@types/ui-react-dom/with-schemas/index.d.cts +0 -1994
  106. package/@types/ui-react-inspector/index.d.cts +0 -79
  107. package/@types/ui-react-inspector/with-schemas/index.d.cts +0 -1985
  108. package/@types/with-schemas/index.d.cts +0 -17
@@ -1,1064 +0,0 @@
1
- /**
2
- * The indexes module of the TinyBase project provides the ability to create and
3
- * track indexes of the data in Store objects.
4
- *
5
- * The main entry point to this module is the createIndexes function, which
6
- * returns a new Indexes object. From there, you can create new Index
7
- * definitions, access the contents of those Indexes directly, and register
8
- * listeners for when they change.
9
- * @packageDocumentation
10
- * @module indexes
11
- * @since v1.0.0
12
- */
13
- import type {Id, IdOrNull, Ids, SortKey} from '../common/index.d.cts';
14
- import type {GetCell, RowCallback, Store} from '../store/index.d.cts';
15
-
16
- /**
17
- * The Index type represents the concept of a map of Slice objects, keyed by Id.
18
- *
19
- * The Ids in a Slice represent Row objects from a Table that all have a derived
20
- * string value in common, as described by the setIndexDefinition method. Those
21
- * values are used as the key for each Slice in the overall Index object.
22
- *
23
- * Note that the Index type is not actually used in the API, and you instead
24
- * enumerate and access its structure with the getSliceIds method and
25
- * getSliceRowIds method.
26
- * @category Concept
27
- * @since v1.0.0
28
- */
29
- export type Index = {[sliceId: Id]: Slice};
30
-
31
- /**
32
- * The Slice type represents the concept of a set of Row objects that comprise
33
- * part of an Index.
34
- *
35
- * The Ids in a Slice represent Row objects from a Table that all have a derived
36
- * string value in common, as described by the setIndexDefinition method.
37
- *
38
- * Note that the Slice type is not actually used in the API, and you instead get
39
- * Row Ids directly with the getSliceRowIds method.
40
- * @category Concept
41
- * @since v1.0.0
42
- */
43
- export type Slice = Ids;
44
-
45
- /**
46
- * The IndexCallback type describes a function that takes an Index's Id and a
47
- * callback to loop over each Slice within it.
48
- *
49
- * A IndexCallback is provided when using the forEachIndex method, so that you
50
- * can do something based on every Index in the Indexes object. See that method
51
- * for specific examples.
52
- * @param indexId The Id of the Index that the callback can operate on.
53
- * @param forEachSlice A function that will let you iterate over the Slice
54
- * objects in this Index.
55
- * @category Callback
56
- * @since v1.0.0
57
- */
58
- export type IndexCallback = (
59
- indexId: Id,
60
- forEachSlice: (sliceCallback: SliceCallback) => void,
61
- ) => void;
62
-
63
- /**
64
- * The SliceCallback type describes a function that takes a Slice's Id and a
65
- * callback to loop over each Row within it.
66
- *
67
- * A SliceCallback is provided when using the forEachSlice method, so that you
68
- * can do something based on every Slice in an Index. See that method for
69
- * specific examples.
70
- * @param sliceId The Id of the Slice that the callback can operate on.
71
- * @param forEachRow A function that will let you iterate over the Row objects
72
- * in this Slice.
73
- * @category Callback
74
- * @since v1.0.0
75
- */
76
- export type SliceCallback = (
77
- sliceId: Id,
78
- forEachRow: (rowCallback: RowCallback) => void,
79
- ) => void;
80
-
81
- /**
82
- * The IndexIdsListener type describes a function that is used to listen to
83
- * Index definitions being added or removed.
84
- *
85
- * A IndexIdsListener is provided when using the addIndexIdsListener method.
86
- * See that method for specific examples.
87
- *
88
- * When called, an IndexIdsListener is given a reference to the Indexes object.
89
- * @param indexes A reference to the Indexes object that changed.
90
- * @category Listener
91
- * @since v1.0.0
92
- */
93
- export type IndexIdsListener = (indexes: Indexes) => void;
94
-
95
- /**
96
- * The SliceIdsListener type describes a function that is used to listen to
97
- * changes to the Slice Ids in an Index.
98
- *
99
- * A SliceIdsListener is provided when using the addSliceIdsListener method. See
100
- * that method for specific examples.
101
- *
102
- * When called, a SliceIdsListener is given a reference to the Indexes object,
103
- * and the Id of the Index that changed.
104
- * @param indexes A reference to the Indexes object that changed.
105
- * @param indexId The Id of the Index that changed.
106
- * @category Listener
107
- * @since v1.0.0
108
- */
109
- export type SliceIdsListener = (indexes: Indexes, indexId: Id) => void;
110
-
111
- /**
112
- * The SliceRowIdsListener type describes a function that is used to listen to
113
- * changes to the Row Ids in a Slice.
114
- *
115
- * A SliceRowIdsListener is provided when using the addSliceRowIdsListener
116
- * method. See that method for specific examples.
117
- *
118
- * When called, a SliceRowIdsListener is given a reference to the Indexes
119
- * object, the Id of the Index that changed, and the Id of the Slice whose Row
120
- * Ids changed.
121
- * @param indexes A reference to the Indexes object that changed.
122
- * @param indexId The Id of the Index that changed.
123
- * @param sliceId The Id of the Slice that changed.
124
- * @category Listener
125
- * @since v1.0.0
126
- */
127
- export type SliceRowIdsListener = (
128
- indexes: Indexes,
129
- indexId: Id,
130
- sliceId: Id,
131
- ) => void;
132
-
133
- /**
134
- * The IndexesListenerStats type describes the number of listeners registered
135
- * with the Indexes object, and can be used for debugging purposes.
136
- *
137
- * A IndexesListenerStats object is returned from the getListenerStats method.
138
- * @category Development
139
- * @since v1.0.0
140
- */
141
- export type IndexesListenerStats = {
142
- /**
143
- * The number of SlideIdsListener functions registered with the Indexes
144
- * object.
145
- * @category Stat
146
- * @since v1.0.0
147
- */
148
- sliceIds: number;
149
- /**
150
- * The number of SliceRowIdsListener functions registered with the Indexes
151
- * object.
152
- * @category Stat
153
- * @since v1.0.0
154
- */
155
- sliceRowIds: number;
156
- };
157
-
158
- /**
159
- * An Indexes object lets you look up all the Row objects in a Table that have a
160
- * certain Cell value.
161
- *
162
- * This is useful for creating filtered views of a Table, or simple search
163
- * functionality.
164
- *
165
- * Create an Indexes object easily with the createIndexes function. From there,
166
- * you can add new Index definitions (with the setIndexDefinition method), query
167
- * their contents (with the getSliceIds method and getSliceRowIds method), and
168
- * add listeners for when they change (with the addSliceIdsListener method and
169
- * addSliceRowIdsListener method).
170
- *
171
- * This module defaults to indexing Row objects by one of their Cell values.
172
- * However, far more complex indexes can be configured with a custom function.
173
- * @example
174
- * This example shows a very simple lifecycle of an Indexes object: from
175
- * creation, to adding a definition, getting its contents, and then registering
176
- * and removing a listener for it.
177
- *
178
- * ```js
179
- * import {createIndexes, createStore} from 'tinybase';
180
- *
181
- * const store = createStore().setTable('pets', {
182
- * fido: {species: 'dog'},
183
- * felix: {species: 'cat'},
184
- * cujo: {species: 'dog'},
185
- * });
186
- *
187
- * const indexes = createIndexes(store);
188
- * indexes.setIndexDefinition(
189
- * 'bySpecies', // indexId
190
- * 'pets', // tableId to index
191
- * 'species', // cellId to index
192
- * );
193
- *
194
- * console.log(indexes.getSliceIds('bySpecies'));
195
- * // -> ['dog', 'cat']
196
- * console.log(indexes.getSliceRowIds('bySpecies', 'dog'));
197
- * // -> ['fido', 'cujo']
198
- *
199
- * const listenerId = indexes.addSliceIdsListener('bySpecies', () => {
200
- * console.log(indexes.getSliceIds('bySpecies'));
201
- * });
202
- * store.setRow('pets', 'lowly', {species: 'worm'});
203
- * // -> ['dog', 'cat', 'worm']
204
- *
205
- * indexes.delListener(listenerId);
206
- * indexes.destroy();
207
- * ```
208
- * @see Using Indexes guides
209
- * @see Rolling Dice demos
210
- * @see Country demo
211
- * @see Todo App demos
212
- * @see Word Frequencies demo
213
- * @category Indexes
214
- * @since v1.0.0
215
- */
216
- export interface Indexes {
217
- //
218
- /**
219
- * The setIndexDefinition method lets you set the definition of an Index.
220
- *
221
- * Every Index definition is identified by a unique Id, and if you re-use an
222
- * existing Id with this method, the previous definition is overwritten.
223
- *
224
- * An Index is a keyed map of Slice objects, each of which is a list of Row
225
- * Ids from a given Table. Therefore the definition must specify the Table (by
226
- * its Id) to be indexed.
227
- *
228
- * The Ids in a Slice represent Row objects from a Table that all have a
229
- * derived string value in common, as described by this method. Those values
230
- * are used as the key for each Slice in the overall Index object.
231
- *
232
- * Without the third `getSliceIdOrIds` parameter, the Index will simply have a
233
- * single Slice, keyed by an empty string. But more often you will specify a
234
- * Cell value containing the Slice Id that the Row should belong to.
235
- * Alternatively, a custom function can be provided that produces your own
236
- * Slice Id from the local Row as a whole. Since v2.1, the custom function can
237
- * return an array of Slice Ids, each of which the Row will then belong to.
238
- *
239
- * The fourth `getSortKey` parameter specifies a Cell Id to get a value (or a
240
- * function that processes a whole Row to get a value) that is used to sort
241
- * the Row Ids within each Slice in the Index.
242
- *
243
- * The fifth parameter, `sliceIdSorter`, lets you specify a way to sort the
244
- * Slice Ids when you access the Index, which may be useful if you are trying
245
- * to create an alphabetic Index of Row entries. If not specified, the order
246
- * of the Slice Ids will match the order of Row insertion.
247
- *
248
- * The final parameter, `rowIdSorter`, lets you specify a way to sort the Row
249
- * Ids within each Slice, based on the `getSortKey` parameter. This may be
250
- * useful if you are trying to keep Rows in a determined order relative to
251
- * each other in the Index. If omitted, the Row Ids are sorted alphabetically,
252
- * based on the `getSortKey` parameter.
253
- *
254
- * The two 'sorter' parameters, `sliceIdSorter` and `rowIdSorter`, are
255
- * functions that take two values and return a positive or negative number for
256
- * when they are in the wrong or right order, respectively. This is exactly
257
- * the same as the 'compareFunction' that is used in the standard JavaScript
258
- * array `sort` method, with the addition that `rowIdSorter` also takes the
259
- * Slice Id parameter, in case you want to sort Row Ids differently in each
260
- * Slice. You can use the convenient defaultSorter function to default this to
261
- * be alphanumeric.
262
- * @param indexId The Id of the Index to define.
263
- * @param tableId The Id of the Table the Index will be generated from.
264
- * @param getSliceIdOrIds Either the Id of the Cell containing, or a function
265
- * that produces, the Id that is used to indicate which Slice in the Index the
266
- * Row Id should be in. Defaults to a function that returns `''` (meaning that
267
- * if this `getSliceIdOrIds` parameter is omitted, the Index will simply
268
- * contain a single Slice containing all the Row Ids in the Table). Since
269
- * v2.1, this can return an array of Slice Ids, each of which the Row will
270
- * then belong to.
271
- * @param getSortKey Either the Id of the Cell containing, or a function that
272
- * produces, the value that is used to sort the Row Ids in each Slice.
273
- * @param sliceIdSorter A function that takes two Slice Id values and returns
274
- * a positive or negative number to indicate how they should be sorted.
275
- * @param rowIdSorter A function that takes two Row Id values (and a slice Id)
276
- * and returns a positive or negative number to indicate how they should be
277
- * sorted.
278
- * @returns A reference to the Indexes object.
279
- * @example
280
- * This example creates a Store, creates an Indexes object, and defines a
281
- * simple Index based on the values in the `species` Cell.
282
- *
283
- * ```js
284
- * import {createIndexes, createStore} from 'tinybase';
285
- *
286
- * const store = createStore().setTable('pets', {
287
- * fido: {species: 'dog'},
288
- * felix: {species: 'cat'},
289
- * cujo: {species: 'dog'},
290
- * });
291
- *
292
- * const indexes = createIndexes(store);
293
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
294
- *
295
- * console.log(indexes.getSliceIds('bySpecies'));
296
- * // -> ['dog', 'cat']
297
- * console.log(indexes.getSliceRowIds('bySpecies', 'dog'));
298
- * // -> ['fido', 'cujo']
299
- * ```
300
- * @example
301
- * This example creates a Store, creates an Indexes object, and defines an
302
- * Index based on the first letter of the pets' names.
303
- *
304
- * ```js
305
- * import {createIndexes, createStore} from 'tinybase';
306
- *
307
- * const store = createStore().setTable('pets', {
308
- * fido: {species: 'dog'},
309
- * felix: {species: 'cat'},
310
- * cujo: {species: 'dog'},
311
- * });
312
- *
313
- * const indexes = createIndexes(store);
314
- * indexes.setIndexDefinition('byFirst', 'pets', (_, rowId) => rowId[0]);
315
- *
316
- * console.log(indexes.getSliceIds('byFirst'));
317
- * // -> ['f', 'c']
318
- * console.log(indexes.getSliceRowIds('byFirst', 'f'));
319
- * // -> ['fido', 'felix']
320
- * ```
321
- * @example
322
- * This example creates a Store, creates an Indexes object, and defines an
323
- * Index based on each of the letters present in the pets' names.
324
- *
325
- * ```js
326
- * import {createIndexes, createStore} from 'tinybase';
327
- *
328
- * const store = createStore().setTable('pets', {
329
- * fido: {species: 'dog'},
330
- * felix: {species: 'cat'},
331
- * rex: {species: 'dog'},
332
- * });
333
- *
334
- * const indexes = createIndexes(store);
335
- * indexes.setIndexDefinition('containsLetter', 'pets', (_, rowId) =>
336
- * rowId.split(''),
337
- * );
338
- *
339
- * console.log(indexes.getSliceIds('containsLetter'));
340
- * // -> ['f', 'i', 'd', 'o', 'e', 'l', 'x', 'r']
341
- * console.log(indexes.getSliceRowIds('containsLetter', 'i'));
342
- * // -> ['fido', 'felix']
343
- * console.log(indexes.getSliceRowIds('containsLetter', 'x'));
344
- * // -> ['felix', 'rex']
345
- * ```
346
- * @example
347
- * This example creates a Store, creates an Indexes object, and defines an
348
- * Index based on the first letter of the pets' names. The Slice Ids (and Row
349
- * Ids within them) are alphabetically sorted.
350
- *
351
- * ```js
352
- * import {createIndexes, createStore, defaultSorter} from 'tinybase';
353
- *
354
- * const store = createStore().setTable('pets', {
355
- * fido: {species: 'dog'},
356
- * felix: {species: 'cat'},
357
- * cujo: {species: 'dog'},
358
- * });
359
- *
360
- * const indexes = createIndexes(store);
361
- * indexes.setIndexDefinition(
362
- * 'byFirst', // indexId
363
- * 'pets', // tableId
364
- * (_, rowId) => rowId[0], // each Row's sliceId
365
- * (_, rowId) => rowId, // each Row's sort key
366
- * defaultSorter, // sort Slice Ids
367
- * defaultSorter, // sort Row Ids
368
- * );
369
- *
370
- * console.log(indexes.getSliceIds('byFirst'));
371
- * // -> ['c', 'f']
372
- * console.log(indexes.getSliceRowIds('byFirst', 'f'));
373
- * // -> ['felix', 'fido']
374
- * ```
375
- * @category Configuration
376
- * @since v1.0.0
377
- */
378
- setIndexDefinition(
379
- indexId: Id,
380
- tableId: Id,
381
- getSliceIdOrIds?: Id | ((getCell: GetCell, rowId: Id) => Id | Ids),
382
- getSortKey?: Id | ((getCell: GetCell, rowId: Id) => SortKey),
383
- sliceIdSorter?: (sliceId1: Id, sliceId2: Id) => number,
384
- rowIdSorter?: (sortKey1: SortKey, sortKey2: SortKey, sliceId: Id) => number,
385
- ): Indexes;
386
-
387
- /**
388
- * The delIndexDefinition method removes an existing Index definition.
389
- * @param indexId The Id of the Index to remove.
390
- * @returns A reference to the Indexes object.
391
- * @example
392
- * This example creates a Store, creates an Indexes object, defines a simple
393
- * Index, and then removes it.
394
- *
395
- * ```js
396
- * import {createIndexes, createStore} from 'tinybase';
397
- *
398
- * const store = createStore().setTable('pets', {
399
- * fido: {species: 'dog'},
400
- * felix: {species: 'cat'},
401
- * cujo: {species: 'dog'},
402
- * });
403
- *
404
- * const indexes = createIndexes(store);
405
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
406
- * console.log(indexes.getIndexIds());
407
- * // -> ['bySpecies']
408
- *
409
- * indexes.delIndexDefinition('bySpecies');
410
- * console.log(indexes.getIndexIds());
411
- * // -> []
412
- * ```
413
- * @category Configuration
414
- * @since v1.0.0
415
- */
416
- delIndexDefinition(indexId: Id): Indexes;
417
-
418
- /**
419
- * The getStore method returns a reference to the underlying Store that is
420
- * backing this Indexes object.
421
- * @returns A reference to the Store.
422
- * @example
423
- * This example creates an Indexes object against a newly-created Store and
424
- * then gets its reference in order to update its data.
425
- *
426
- * ```js
427
- * import {createIndexes, createStore} from 'tinybase';
428
- *
429
- * const indexes = createIndexes(createStore());
430
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
431
- * indexes.getStore().setCell('pets', 'fido', 'species', 'dog');
432
- * console.log(indexes.getSliceIds('bySpecies'));
433
- * // -> ['dog']
434
- * ```
435
- * @category Getter
436
- * @since v1.0.0
437
- */
438
- getStore(): Store;
439
-
440
- /**
441
- * The getIndexIds method returns an array of the Index Ids registered with
442
- * this Indexes object.
443
- * @returns An array of Ids.
444
- * @example
445
- * This example creates an Indexes object with two definitions, and then gets
446
- * the Ids of the definitions.
447
- *
448
- * ```js
449
- * import {createIndexes, createStore} from 'tinybase';
450
- *
451
- * const indexes = createIndexes(createStore())
452
- * .setIndexDefinition('bySpecies', 'pets', 'species')
453
- * .setIndexDefinition('byColor', 'pets', 'color');
454
- *
455
- * console.log(indexes.getIndexIds());
456
- * // -> ['bySpecies', 'byColor']
457
- * ```
458
- * @category Getter
459
- * @since v1.0.0
460
- */
461
- getIndexIds(): Ids;
462
-
463
- /**
464
- * The forEachIndex method takes a function that it will then call for each
465
- * Index in a specified Indexes object.
466
- *
467
- * This method is useful for iterating over the structure of the Indexes
468
- * object in a functional style. The `indexCallback` parameter is a
469
- * IndexCallback function that will be called with the Id of each Index, and
470
- * with a function that can then be used to iterate over each Slice of the
471
- * Index, should you wish.
472
- * @param indexCallback The function that should be called for every Index.
473
- * @example
474
- * This example iterates over each Index in an Indexes object, and lists each
475
- * Slice Id within them.
476
- *
477
- * ```js
478
- * import {createIndexes, createStore} from 'tinybase';
479
- *
480
- * const store = createStore().setTable('pets', {
481
- * fido: {species: 'dog', color: 'brown'},
482
- * felix: {species: 'cat', color: 'black'},
483
- * cujo: {species: 'dog', color: 'black'},
484
- * });
485
- * const indexes = createIndexes(store)
486
- * .setIndexDefinition('bySpecies', 'pets', 'species')
487
- * .setIndexDefinition('byColor', 'pets', 'color');
488
- *
489
- * indexes.forEachIndex((indexId, forEachSlice) => {
490
- * console.log(indexId);
491
- * forEachSlice((sliceId) => console.log(`- ${sliceId}`));
492
- * });
493
- * // -> 'bySpecies'
494
- * // -> '- dog'
495
- * // -> '- cat'
496
- * // -> 'byColor'
497
- * // -> '- brown'
498
- * // -> '- black'
499
- * ```
500
- * @category Iterator
501
- * @since v1.0.0
502
- */
503
- forEachIndex(indexCallback: IndexCallback): void;
504
-
505
- /**
506
- * The forEachSlice method takes a function that it will then call for each
507
- * Slice in a specified Index.
508
- *
509
- * This method is useful for iterating over the Slice structure of the Index
510
- * in a functional style. The `rowCallback` parameter is a RowCallback
511
- * function that will be called with the Id and value of each Row in the
512
- * Slice.
513
- * @param indexId The Id of the Index to iterate over.
514
- * @param sliceCallback The function that should be called for every Slice.
515
- * @example
516
- * This example iterates over each Row in a Slice, and lists its Id.
517
- *
518
- * ```js
519
- * import {createIndexes, createStore} from 'tinybase';
520
- *
521
- * const store = createStore().setTable('pets', {
522
- * fido: {species: 'dog'},
523
- * felix: {species: 'cat'},
524
- * cujo: {species: 'dog'},
525
- * });
526
- * const indexes = createIndexes(store);
527
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
528
- *
529
- * indexes.forEachSlice('bySpecies', (sliceId, forEachRow) => {
530
- * console.log(sliceId);
531
- * forEachRow((rowId) => console.log(`- ${rowId}`));
532
- * });
533
- * // -> 'dog'
534
- * // -> '- fido'
535
- * // -> '- cujo'
536
- * // -> 'cat'
537
- * // -> '- felix'
538
- * ```
539
- * @category Iterator
540
- * @since v1.0.0
541
- */
542
- forEachSlice(indexId: Id, sliceCallback: SliceCallback): void;
543
-
544
- /**
545
- * The hasIndex method returns a boolean indicating whether a given Index
546
- * exists in the Indexes object.
547
- * @param indexId The Id of a possible Index in the Indexes object.
548
- * @returns Whether an Index with that Id exists.
549
- * @example
550
- * This example shows two simple Index existence checks.
551
- *
552
- * ```js
553
- * import {createIndexes, createStore} from 'tinybase';
554
- *
555
- * const indexes = createIndexes(createStore());
556
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
557
- * console.log(indexes.hasIndex('bySpecies'));
558
- * // -> true
559
- * console.log(indexes.hasIndex('byColor'));
560
- * // -> false
561
- * ```
562
- * @category Getter
563
- * @since v1.0.0
564
- */
565
- hasIndex(indexId: Id): boolean;
566
-
567
- /**
568
- * The hasSlice method returns a boolean indicating whether a given Slice
569
- * exists in the Indexes object.
570
- * @param indexId The Id of a possible Index in the Indexes object.
571
- * @param sliceId The Id of a possible Slice in the Index.
572
- * @returns Whether a Slice with that Id exists.
573
- * @example
574
- * This example shows two simple Index existence checks.
575
- *
576
- * ```js
577
- * import {createIndexes, createStore} from 'tinybase';
578
- *
579
- * const store = createStore().setTable('pets', {
580
- * fido: {species: 'dog'},
581
- * felix: {species: 'cat'},
582
- * cujo: {species: 'dog'},
583
- * });
584
- * const indexes = createIndexes(store);
585
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
586
- * console.log(indexes.hasSlice('bySpecies', 'dog'));
587
- * // -> true
588
- * console.log(indexes.hasSlice('bySpecies', 'worm'));
589
- * // -> false
590
- * ```
591
- * @category Getter
592
- * @since v1.0.0
593
- */
594
- hasSlice(indexId: Id, sliceId: Id): boolean;
595
-
596
- /**
597
- * The getTableId method returns the Id of the underlying Table that is
598
- * backing an Index.
599
- *
600
- * If the Index Id is invalid, the method returns `undefined`.
601
- * @param indexId The Id of an Index.
602
- * @returns The Id of the Table backing the Index, or `undefined`.
603
- * @example
604
- * This example creates an Indexes object, a single Index definition, and then
605
- * queries it (and a non-existent definition) to get the underlying Table Id.
606
- *
607
- * ```js
608
- * import {createIndexes, createStore} from 'tinybase';
609
- *
610
- * const indexes = createIndexes(createStore());
611
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
612
- *
613
- * console.log(indexes.getTableId('bySpecies'));
614
- * // -> 'pets'
615
- * console.log(indexes.getTableId('byColor'));
616
- * // -> undefined
617
- * ```
618
- * @category Getter
619
- * @since v1.0.0
620
- */
621
- getTableId(indexId: Id): Id | undefined;
622
-
623
- /**
624
- * The getSliceIds method gets the list of Slice Ids in an Index.
625
- *
626
- * If the identified Index does not exist (or if the definition references a
627
- * Table that does not exist) then an empty array is returned.
628
- * @param indexId The Id of the Index.
629
- * @returns The Slice Ids in the Index, or an empty array.
630
- * @example
631
- * This example creates a Store, creates an Indexes object, and defines a
632
- * simple Index. It then uses getSliceIds to see the available Slice Ids in
633
- * the Index (and also the Slice Ids in an Index that has not been defined).
634
- *
635
- * ```js
636
- * import {createIndexes, createStore} from 'tinybase';
637
- *
638
- * const store = createStore().setTable('pets', {
639
- * fido: {species: 'dog'},
640
- * felix: {species: 'cat'},
641
- * cujo: {species: 'dog'},
642
- * });
643
- *
644
- * const indexes = createIndexes(store);
645
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
646
- *
647
- * console.log(indexes.getSliceIds('bySpecies'));
648
- * // -> ['dog', 'cat']
649
- * console.log(indexes.getSliceIds('byColor'));
650
- * // -> []
651
- * ```
652
- * @category Getter
653
- * @since v1.0.0
654
- */
655
- getSliceIds(indexId: Id): Ids;
656
-
657
- /**
658
- * The getSliceRowIds method gets the list of Row Ids in a given Slice, within
659
- * a given Index.
660
- *
661
- * If the identified Index or Slice do not exist (or if the definition
662
- * references a Table that does not exist) then an empty array is returned.
663
- * @param indexId The Id of the Index.
664
- * @param sliceId The Id of the Slice in the Index.
665
- * @returns The Row Ids in the Slice, or an empty array.
666
- * @example
667
- * This example creates a Store, creates an Indexes object, and defines a
668
- * simple Index. It then uses getSliceRowIds to see the Row Ids in the Slice
669
- * (and also the Row Ids in Slices that do not exist).
670
- *
671
- * ```js
672
- * import {createIndexes, createStore} from 'tinybase';
673
- *
674
- * const store = createStore().setTable('pets', {
675
- * fido: {species: 'dog'},
676
- * felix: {species: 'cat'},
677
- * cujo: {species: 'dog'},
678
- * });
679
- *
680
- * const indexes = createIndexes(store);
681
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
682
- *
683
- * console.log(indexes.getSliceRowIds('bySpecies', 'dog'));
684
- * // -> ['fido', 'cujo']
685
- * console.log(indexes.getSliceRowIds('bySpecies', 'worm'));
686
- * // -> []
687
- * console.log(indexes.getSliceRowIds('byColor', 'brown'));
688
- * // -> []
689
- * ```
690
- * @category Getter
691
- * @since v1.0.0
692
- */
693
- getSliceRowIds(indexId: Id, sliceId: Id): Ids;
694
-
695
- /**
696
- * The addSliceIdsListener method registers a listener function with the
697
- * Indexes object that will be called whenever the Slice Ids in an Index
698
- * change.
699
- *
700
- * You can either listen to a single Index (by specifying the Index Id as the
701
- * method's first parameter), or changes to any Index (by providing a `null`
702
- * wildcard).
703
- *
704
- * The provided listener is a SliceIdsListener function, and will be called
705
- * with a reference to the Indexes object, and the Id of the Index that
706
- * changed.
707
- * @param indexId The Id of the Index to listen to, or `null` as a wildcard.
708
- * @param listener The function that will be called whenever the Slice Ids in
709
- * the Index change.
710
- * @returns A unique Id for the listener that can later be used to remove it.
711
- * @example
712
- * This example creates a Store, an Indexes object, and then registers a
713
- * listener that responds to any changes to a specific Index.
714
- *
715
- * ```js
716
- * import {createIndexes, createStore} from 'tinybase';
717
- *
718
- * const store = createStore().setTable('pets', {
719
- * fido: {species: 'dog'},
720
- * felix: {species: 'cat'},
721
- * cujo: {species: 'dog'},
722
- * });
723
- *
724
- * const indexes = createIndexes(store);
725
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
726
- *
727
- * const listenerId = indexes.addSliceIdsListener('bySpecies', (indexes) => {
728
- * console.log('Slice Ids for bySpecies index changed');
729
- * console.log(indexes.getSliceIds('bySpecies'));
730
- * });
731
- *
732
- * store.setRow('pets', 'lowly', {species: 'worm'});
733
- * // -> 'Slice Ids for bySpecies index changed'
734
- * // -> ['dog', 'cat', 'worm']
735
- *
736
- * indexes.delListener(listenerId);
737
- * ```
738
- * @example
739
- * This example creates a Store, an Indexes object, and then registers a
740
- * listener that responds to any changes to any Index.
741
- *
742
- * ```js
743
- * import {createIndexes, createStore} from 'tinybase';
744
- *
745
- * const store = createStore().setTable('pets', {
746
- * fido: {species: 'dog', color: 'brown'},
747
- * felix: {species: 'cat', color: 'black'},
748
- * cujo: {species: 'dog', color: 'brown'},
749
- * });
750
- *
751
- * const indexes = createIndexes(store)
752
- * .setIndexDefinition('bySpecies', 'pets', 'species')
753
- * .setIndexDefinition('byColor', 'pets', 'color');
754
- *
755
- * const listenerId = indexes.addSliceIdsListener(
756
- * null,
757
- * (indexes, indexId) => {
758
- * console.log(`Slice Ids for ${indexId} index changed`);
759
- * console.log(indexes.getSliceIds(indexId));
760
- * },
761
- * );
762
- *
763
- * store.setRow('pets', 'lowly', {species: 'worm', color: 'pink'});
764
- * // -> 'Slice Ids for bySpecies index changed'
765
- * // -> ['dog', 'cat', 'worm']
766
- * // -> 'Slice Ids for byColor index changed'
767
- * // -> ['brown', 'black', 'pink']
768
- *
769
- * indexes.delListener(listenerId);
770
- * ```
771
- * @category Listener
772
- * @since v1.0.0
773
- */
774
- addSliceIdsListener(indexId: IdOrNull, listener: SliceIdsListener): Id;
775
-
776
- /**
777
- * The addIndexIdsListener method registers a listener function with the
778
- * Indexes object that will be called whenever an Index definition is added or
779
- * removed.
780
- *
781
- * The provided listener is an IndexIdsListener function, and will be called
782
- * with a reference to the Indexes object.
783
- * @param listener The function that will be called whenever an Index
784
- * definition is added or removed.
785
- * @example
786
- * This example creates a Store, an Indexes object, and then registers a
787
- * listener that responds to the addition and the removal of an Index
788
- * definition.
789
- *
790
- * ```js
791
- * import {createIndexes, createStore} from 'tinybase';
792
- *
793
- * const store = createStore().setTable('pets', {
794
- * fido: {species: 'dog'},
795
- * felix: {species: 'cat'},
796
- * cujo: {species: 'dog'},
797
- * });
798
- *
799
- * const indexes = createIndexes(store);
800
- * const listenerId = indexes.addIndexIdsListener((indexes) => {
801
- * console.log(indexes.getIndexIds());
802
- * });
803
- *
804
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
805
- * // -> ['bySpecies']
806
- * indexes.delIndexDefinition('bySpecies');
807
- * // -> []
808
- *
809
- * indexes.delListener(listenerId);
810
- * ```
811
- * @category Listener
812
- * @since v4.1.0
813
- */
814
- addIndexIdsListener(listener: IndexIdsListener): Id;
815
-
816
- /**
817
- * The addSliceRowIdsListener method registers a listener function with the
818
- * Indexes object that will be called whenever the Row Ids in a Slice change.
819
- *
820
- * You can either listen to a single Slice (by specifying the Index Id and
821
- * Slice Id as the method's first two parameters), or changes to any Slice (by
822
- * providing `null` wildcards).
823
- *
824
- * Both, either, or neither of the `indexId` and `sliceId` parameters can be
825
- * wildcarded with `null`. You can listen to a specific Slice in a specific
826
- * Index, any Slice in a specific Index, a specific Slice in any Index, or any
827
- * Slice in any Index.
828
- *
829
- * The provided listener is a SliceRowIdsListener function, and will be called
830
- * with a reference to the Indexes object, the Id of the Index, and the Id of
831
- * the Slice that changed.
832
- * @param indexId The Id of the Index to listen to, or `null` as a wildcard.
833
- * @param sliceId The Id of the Slice to listen to, or `null` as a wildcard.
834
- * @param listener The function that will be called whenever the Row Ids in
835
- * the Slice change.
836
- * @returns A unique Id for the listener that can later be used to remove it.
837
- * @example
838
- * This example creates a Store, an Indexes object, and then registers a
839
- * listener that responds to any changes to a specific Slice.
840
- *
841
- * ```js
842
- * import {createIndexes, createStore} from 'tinybase';
843
- *
844
- * const store = createStore().setTable('pets', {
845
- * fido: {species: 'dog'},
846
- * felix: {species: 'cat'},
847
- * cujo: {species: 'dog'},
848
- * });
849
- *
850
- * const indexes = createIndexes(store);
851
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
852
- *
853
- * const listenerId = indexes.addSliceRowIdsListener(
854
- * 'bySpecies',
855
- * 'dog',
856
- * (indexes) => {
857
- * console.log('Row Ids for dog slice in bySpecies index changed');
858
- * console.log(indexes.getSliceRowIds('bySpecies', 'dog'));
859
- * },
860
- * );
861
- *
862
- * store.setRow('pets', 'toto', {species: 'dog'});
863
- * // -> 'Row Ids for dog slice in bySpecies index changed'
864
- * // -> ['fido', 'cujo', 'toto']
865
- *
866
- * indexes.delListener(listenerId);
867
- * ```
868
- * @example
869
- * This example creates a Store, an Indexes object, and then registers a
870
- * listener that responds to any changes to any Slice.
871
- *
872
- * ```js
873
- * import {createIndexes, createStore} from 'tinybase';
874
- *
875
- * const store = createStore().setTable('pets', {
876
- * fido: {species: 'dog', color: 'brown'},
877
- * felix: {species: 'cat', color: 'black'},
878
- * cujo: {species: 'dog', color: 'black'},
879
- * });
880
- *
881
- * const indexes = createIndexes(store)
882
- * .setIndexDefinition('bySpecies', 'pets', 'species')
883
- * .setIndexDefinition('byColor', 'pets', 'color');
884
- *
885
- * const listenerId = indexes.addSliceRowIdsListener(
886
- * null,
887
- * null,
888
- * (indexes, indexId, sliceId) => {
889
- * console.log(
890
- * `Row Ids for ${sliceId} slice in ${indexId} index changed`,
891
- * );
892
- * console.log(indexes.getSliceRowIds(indexId, sliceId));
893
- * },
894
- * );
895
- *
896
- * store.setRow('pets', 'toto', {species: 'dog', color: 'brown'});
897
- * // -> 'Row Ids for dog slice in bySpecies index changed'
898
- * // -> ['fido', 'cujo', 'toto']
899
- * // -> 'Row Ids for brown slice in byColor index changed'
900
- * // -> ['fido', 'toto']
901
- *
902
- * indexes.delListener(listenerId);
903
- * ```
904
- * @category Listener
905
- * @since v1.0.0
906
- */
907
- addSliceRowIdsListener(
908
- indexId: IdOrNull,
909
- sliceId: IdOrNull,
910
- listener: SliceRowIdsListener,
911
- ): Id;
912
-
913
- /**
914
- * The delListener method removes a listener that was previously added to the
915
- * Indexes object.
916
- *
917
- * Use the Id returned by whichever method was used to add the listener. Note
918
- * that the Indexes object may re-use this Id for future listeners added to
919
- * it.
920
- * @param listenerId The Id of the listener to remove.
921
- * @returns A reference to the Indexes object.
922
- * @example
923
- * This example creates a Store, an Indexes object, registers a listener, and
924
- * then removes it.
925
- *
926
- * ```js
927
- * import {createIndexes, createStore} from 'tinybase';
928
- *
929
- * const store = createStore().setTable('pets', {
930
- * fido: {species: 'dog'},
931
- * felix: {species: 'cat'},
932
- * cujo: {species: 'dog'},
933
- * });
934
- *
935
- * const indexes = createIndexes(store);
936
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
937
- *
938
- * const listenerId = indexes.addSliceIdsListener('bySpecies', () => {
939
- * console.log('Slice Ids for bySpecies index changed');
940
- * });
941
- *
942
- * store.setRow('pets', 'lowly', {species: 'worm'});
943
- * // -> 'Slice Ids for bySpecies index changed'
944
- *
945
- * indexes.delListener(listenerId);
946
- *
947
- * store.setRow('pets', 'toto', {species: 'dog'});
948
- * // -> undefined
949
- * // The listener is not called.
950
- * ```
951
- * @category Listener
952
- * @since v1.0.0
953
- */
954
- delListener(listenerId: Id): Indexes;
955
-
956
- /**
957
- * The destroy method should be called when this Indexes object is no longer
958
- * used.
959
- *
960
- * This guarantees that all of the listeners that the object registered with
961
- * the underlying Store are removed and it can be correctly garbage collected.
962
- * @example
963
- * This example creates a Store, adds an Indexes object with a
964
- * definition (that registers a RowListener with the underlying Store),
965
- * and then destroys it again, removing the listener.
966
- *
967
- * ```js
968
- * import {createIndexes, createStore} from 'tinybase';
969
- *
970
- * const store = createStore().setTable('pets', {
971
- * fido: {species: 'dog'},
972
- * felix: {species: 'cat'},
973
- * cujo: {species: 'dog'},
974
- * });
975
- *
976
- * const indexes = createIndexes(store);
977
- * indexes.setIndexDefinition('bySpecies', 'pets', 'species');
978
- * console.log(store.getListenerStats().row);
979
- * // -> 1
980
- *
981
- * indexes.destroy();
982
- *
983
- * console.log(store.getListenerStats().row);
984
- * // -> 0
985
- * ```
986
- * @category Lifecycle
987
- * @since v1.0.0
988
- */
989
- destroy(): void;
990
-
991
- /**
992
- * The getListenerStats method provides a set of statistics about the
993
- * listeners registered with the Indexes object, and is used for debugging
994
- * purposes.
995
- *
996
- * The IndexesListenerStats object contains a breakdown of the different types
997
- * of listener.
998
- *
999
- * The method is intended to be used during development to ensure your
1000
- * application is not leaking listener registrations, for example.
1001
- * @returns A IndexesListenerStats object containing Indexes listener
1002
- * statistics.
1003
- * @example
1004
- * This example gets the listener statistics of an Indexes object.
1005
- *
1006
- * ```js
1007
- * import {createIndexes, createStore} from 'tinybase';
1008
- *
1009
- * const store = createStore();
1010
- * const indexes = createIndexes(store);
1011
- * indexes.addSliceIdsListener(null, () => {
1012
- * console.log('Slice Ids changed');
1013
- * });
1014
- * indexes.addSliceRowIdsListener(null, null, () => {
1015
- * console.log('Slice Row Ids changed');
1016
- * });
1017
- *
1018
- * console.log(indexes.getListenerStats());
1019
- * // -> {sliceIds: 1, sliceRowIds: 1}
1020
- * ```
1021
- * @category Development
1022
- * @since v1.0.0
1023
- */
1024
- getListenerStats(): IndexesListenerStats;
1025
- //
1026
- }
1027
-
1028
- /**
1029
- * The createIndexes function creates an Indexes object, and is the main entry
1030
- * point into the indexes module.
1031
- *
1032
- * A given Store can only have one Indexes object associated with it. If you
1033
- * call this function twice on the same Store, your second call will return a
1034
- * reference to the Indexes object created by the first.
1035
- * @param store The Store for which to register Index definitions.
1036
- * @returns A reference to the new Indexes object.
1037
- * @example
1038
- * This example creates an Indexes object.
1039
- *
1040
- * ```js
1041
- * import {createIndexes, createStore} from 'tinybase';
1042
- *
1043
- * const store = createStore();
1044
- * const indexes = createIndexes(store);
1045
- * console.log(indexes.getIndexIds());
1046
- * // -> []
1047
- * ```
1048
- * @example
1049
- * This example creates an Indexes object, and calls the method a second time
1050
- * for the same Store to return the same object.
1051
- *
1052
- * ```js
1053
- * import {createIndexes, createStore} from 'tinybase';
1054
- *
1055
- * const store = createStore();
1056
- * const indexes1 = createIndexes(store);
1057
- * const indexes2 = createIndexes(store);
1058
- * console.log(indexes1 === indexes2);
1059
- * // -> true
1060
- * ```
1061
- * @category Creation
1062
- * @since v1.0.0
1063
- */
1064
- export function createIndexes(store: Store): Indexes;