tinybase 3.1.0-beta.4 → 3.1.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.
- package/lib/debug/ui-react.js +2 -2
- package/lib/{checkpoints.d.ts → types/checkpoints.d.ts} +13 -13
- package/lib/{debug → types}/indexes.d.ts +10 -16
- package/lib/{debug → types}/metrics.d.ts +49 -50
- package/lib/{debug → types}/persisters.d.ts +26 -30
- package/lib/{cjs-es6 → types}/queries.d.ts +474 -309
- package/lib/{debug → types}/relationships.d.ts +11 -17
- package/lib/{debug → types}/store.d.ts +180 -1038
- package/lib/types/tinybase.d.ts +14 -0
- package/lib/{debug → types}/tools.d.ts +12 -12
- package/lib/{debug → types}/ui-react.d.ts +11 -5
- package/lib/{cjs-es6 → types/with-schemas}/checkpoints.d.ts +93 -7
- package/lib/{cjs → types/with-schemas}/indexes.d.ts +136 -18
- package/lib/types/with-schemas/internal/queries.d.ts +15 -0
- package/lib/types/with-schemas/internal/store.d.ts +101 -0
- package/lib/types/with-schemas/internal/ui-react.d.ts +776 -0
- package/lib/{cjs → types/with-schemas}/metrics.d.ts +115 -50
- package/lib/{cjs → types/with-schemas}/persisters.d.ts +102 -4
- package/lib/{debug → types/with-schemas}/queries.d.ts +865 -346
- package/lib/{cjs → types/with-schemas}/relationships.d.ts +151 -20
- package/lib/{cjs-es6 → types/with-schemas}/store.d.ts +1082 -801
- package/lib/types/with-schemas/tinybase.d.ts +14 -0
- package/lib/{cjs-es6 → types/with-schemas}/tools.d.ts +21 -10
- package/lib/{cjs-es6 → types/with-schemas}/ui-react.d.ts +1871 -1314
- package/package.json +145 -29
- package/readme.md +14 -14
- package/lib/cjs/checkpoints.d.ts +0 -961
- package/lib/cjs/queries.d.ts +0 -3028
- package/lib/cjs/store.d.ts +0 -6143
- package/lib/cjs/tinybase.d.ts +0 -14
- package/lib/cjs/tools.d.ts +0 -536
- package/lib/cjs/ui-react.d.ts +0 -10921
- package/lib/cjs-es6/indexes.d.ts +0 -974
- package/lib/cjs-es6/metrics.d.ts +0 -829
- package/lib/cjs-es6/persisters.d.ts +0 -733
- package/lib/cjs-es6/relationships.d.ts +0 -1209
- package/lib/cjs-es6/tinybase.d.ts +0 -14
- package/lib/common.d.ts +0 -115
- package/lib/debug/checkpoints.d.ts +0 -961
- package/lib/debug/common.d.ts +0 -115
- package/lib/debug/tinybase.d.ts +0 -14
- package/lib/es6/checkpoints.d.ts +0 -961
- package/lib/es6/common.d.ts +0 -115
- package/lib/es6/indexes.d.ts +0 -974
- package/lib/es6/metrics.d.ts +0 -829
- package/lib/es6/persisters.d.ts +0 -733
- package/lib/es6/queries.d.ts +0 -3028
- package/lib/es6/relationships.d.ts +0 -1209
- package/lib/es6/store.d.ts +0 -6143
- package/lib/es6/tinybase.d.ts +0 -14
- package/lib/es6/tools.d.ts +0 -536
- package/lib/es6/ui-react.d.ts +0 -10921
- package/lib/indexes.d.ts +0 -974
- package/lib/metrics.d.ts +0 -829
- package/lib/persisters.d.ts +0 -733
- package/lib/queries.d.ts +0 -3028
- package/lib/relationships.d.ts +0 -1209
- package/lib/store.d.ts +0 -6143
- package/lib/tinybase.d.ts +0 -14
- package/lib/tools.d.ts +0 -536
- package/lib/ui-react.d.ts +0 -10921
- package/lib/umd/checkpoints.d.ts +0 -961
- package/lib/umd/common.d.ts +0 -115
- package/lib/umd/indexes.d.ts +0 -974
- package/lib/umd/metrics.d.ts +0 -829
- package/lib/umd/persisters.d.ts +0 -733
- package/lib/umd/queries.d.ts +0 -3028
- package/lib/umd/relationships.d.ts +0 -1209
- package/lib/umd/store.d.ts +0 -6143
- package/lib/umd/tinybase.d.ts +0 -14
- package/lib/umd/tools.d.ts +0 -536
- package/lib/umd/ui-react.d.ts +0 -10921
- package/lib/umd-es6/checkpoints.d.ts +0 -961
- package/lib/umd-es6/common.d.ts +0 -115
- package/lib/umd-es6/indexes.d.ts +0 -974
- package/lib/umd-es6/metrics.d.ts +0 -829
- package/lib/umd-es6/persisters.d.ts +0 -733
- package/lib/umd-es6/queries.d.ts +0 -3028
- package/lib/umd-es6/relationships.d.ts +0 -1209
- package/lib/umd-es6/store.d.ts +0 -6143
- package/lib/umd-es6/tinybase.d.ts +0 -14
- package/lib/umd-es6/tools.d.ts +0 -536
- package/lib/umd-es6/ui-react.d.ts +0 -10921
- /package/lib/{cjs-es6 → types}/common.d.ts +0 -0
- /package/lib/{cjs → types/with-schemas}/common.d.ts +0 -0
|
@@ -12,22 +12,71 @@
|
|
|
12
12
|
* @since v2.0.0
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
Cell,
|
|
17
|
-
CellCallback,
|
|
18
|
-
CellOrUndefined,
|
|
19
|
-
GetCell,
|
|
20
|
-
GetCellChange,
|
|
21
|
-
NoSchemas,
|
|
22
|
-
OptionalSchemas,
|
|
23
|
-
Row,
|
|
24
|
-
RowCallback,
|
|
25
|
-
Store,
|
|
26
|
-
Table,
|
|
27
|
-
TableCallback,
|
|
28
|
-
} from './store.d';
|
|
15
|
+
import {Cell, CellOrUndefined, GetCell, Store} from './store.d';
|
|
29
16
|
import {Id, IdOrNull, Ids} from './common.d';
|
|
30
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The ResultTable type is the data structure representing the results of a
|
|
20
|
+
* query.
|
|
21
|
+
*
|
|
22
|
+
* A ResultTable is typically accessed with the getResultTable method or
|
|
23
|
+
* addResultTableListener method. It is similar to the Table type in the store
|
|
24
|
+
* module, but without schema-specific typing, and is a regular JavaScript
|
|
25
|
+
* object containing individual ResultRow objects, keyed by their Id.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```js
|
|
29
|
+
* const resultTable: ResultTable = {
|
|
30
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
31
|
+
* felix: {species: 'cat'},
|
|
32
|
+
* };
|
|
33
|
+
* ```
|
|
34
|
+
* @category Result
|
|
35
|
+
*/
|
|
36
|
+
export type ResultTable = {[rowId: Id]: ResultRow};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The ResultRow type is the data structure representing a single row in the
|
|
40
|
+
* results of a query.
|
|
41
|
+
*
|
|
42
|
+
* A ResultRow is typically accessed with the getResultRow method or
|
|
43
|
+
* addResultRowListener method. It is similar to the Row type in the store
|
|
44
|
+
* module, but without schema-specific typing, and is a regular JavaScript
|
|
45
|
+
* object containing individual ResultCell objects, keyed by their Id.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```js
|
|
49
|
+
* const resultRow: ResultRow = {species: 'dog', color: 'brown'};
|
|
50
|
+
* ```
|
|
51
|
+
* @category Result
|
|
52
|
+
*/
|
|
53
|
+
export type ResultRow = {[cellId: Id]: ResultCell};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The ResultCell type is the data structure representing a single cell in the
|
|
57
|
+
* results of a query.
|
|
58
|
+
*
|
|
59
|
+
* A ResultCell is typically accessed with the getResultCell method or
|
|
60
|
+
* addResultCellListener method. It is similar to the Cell type in the store
|
|
61
|
+
* module, but without schema-specific typing, and is a JavaScript string,
|
|
62
|
+
* number, or boolean.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```js
|
|
66
|
+
* const resultCell: ResultCell = 'dog';
|
|
67
|
+
* ```
|
|
68
|
+
* @category Result
|
|
69
|
+
*/
|
|
70
|
+
export type ResultCell = string | number | boolean;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The ResultCellOrUndefined type is the data structure representing a single
|
|
74
|
+
* cell in the results of a query, or the value `undefined`.
|
|
75
|
+
*
|
|
76
|
+
* @category Result
|
|
77
|
+
*/
|
|
78
|
+
export type ResultCellOrUndefined = ResultCell | undefined;
|
|
79
|
+
|
|
31
80
|
/**
|
|
32
81
|
* The Aggregate type describes a custom function that takes an array of Cell
|
|
33
82
|
* values and returns an aggregate of them.
|
|
@@ -42,7 +91,7 @@ import {Id, IdOrNull, Ids} from './common.d';
|
|
|
42
91
|
* @category Aggregators
|
|
43
92
|
* @since v2.0.0
|
|
44
93
|
*/
|
|
45
|
-
export type Aggregate = (cells: Cell[], length: number) =>
|
|
94
|
+
export type Aggregate = (cells: Cell[], length: number) => ResultCell;
|
|
46
95
|
|
|
47
96
|
/**
|
|
48
97
|
* The AggregateAdd type describes a function that can be used to optimize a
|
|
@@ -72,7 +121,7 @@ export type AggregateAdd = (
|
|
|
72
121
|
current: Cell,
|
|
73
122
|
add: Cell,
|
|
74
123
|
length: number,
|
|
75
|
-
) =>
|
|
124
|
+
) => ResultCellOrUndefined;
|
|
76
125
|
|
|
77
126
|
/**
|
|
78
127
|
* The AggregateRemove type describes a function that can be used to optimize a
|
|
@@ -105,7 +154,7 @@ export type AggregateRemove = (
|
|
|
105
154
|
current: Cell,
|
|
106
155
|
remove: Cell,
|
|
107
156
|
length: number,
|
|
108
|
-
) =>
|
|
157
|
+
) => ResultCellOrUndefined;
|
|
109
158
|
|
|
110
159
|
/**
|
|
111
160
|
* The AggregateReplace type describes a function that can be used to optimize a
|
|
@@ -138,7 +187,7 @@ export type AggregateReplace = (
|
|
|
138
187
|
add: Cell,
|
|
139
188
|
remove: Cell,
|
|
140
189
|
length: number,
|
|
141
|
-
) =>
|
|
190
|
+
) => ResultCellOrUndefined;
|
|
142
191
|
|
|
143
192
|
/**
|
|
144
193
|
* The QueryCallback type describes a function that takes a query's Id.
|
|
@@ -153,44 +202,96 @@ export type AggregateReplace = (
|
|
|
153
202
|
*/
|
|
154
203
|
export type QueryCallback = (queryId: Id) => void;
|
|
155
204
|
|
|
205
|
+
/**
|
|
206
|
+
* The ResultTableCallback type describes a function that takes a ResultTable's
|
|
207
|
+
* Id and a callback to loop over each ResultRow within it.
|
|
208
|
+
*
|
|
209
|
+
* A ResultTableCallback is provided when using the forEachResultTable method,
|
|
210
|
+
* so that you can do something based on every ResultTable in the Queries
|
|
211
|
+
* object. See that method for specific examples.
|
|
212
|
+
*
|
|
213
|
+
* @param tableId The Id of the ResultTable that the callback can operate on.
|
|
214
|
+
* @param forEachRow A function that will let you iterate over the ResultRow
|
|
215
|
+
* objects in this ResultTable.
|
|
216
|
+
* @category Callback
|
|
217
|
+
*/
|
|
218
|
+
export type ResultTableCallback = (
|
|
219
|
+
tableId: Id,
|
|
220
|
+
forEachRow: (rowCallback: ResultRowCallback) => void,
|
|
221
|
+
) => void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* The ResultRowCallback type describes a function that takes a ResultRow's Id
|
|
225
|
+
* and a callback to loop over each ResultCell within it.
|
|
226
|
+
*
|
|
227
|
+
* A ResultRowCallback is provided when using the forEachResultRow method, so
|
|
228
|
+
* that you can do something based on every ResultRow in a ResultTable. See that
|
|
229
|
+
* method for specific examples.
|
|
230
|
+
*
|
|
231
|
+
* @param rowId The Id of the ResultRow that the callback can operate on.
|
|
232
|
+
* @param forEachRow A function that will let you iterate over the ResultCell
|
|
233
|
+
* values in this ResultRow.
|
|
234
|
+
* @category Callback
|
|
235
|
+
*/
|
|
236
|
+
export type ResultRowCallback = (
|
|
237
|
+
rowId: Id,
|
|
238
|
+
forEachCell: (cellCallback: ResultCellCallback) => void,
|
|
239
|
+
) => void;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The ResultCellCallback type describes a function that takes a ResultCell's Id
|
|
243
|
+
* and its value.
|
|
244
|
+
*
|
|
245
|
+
* A ResultCellCallback is provided when using the forEachResultCell method, so
|
|
246
|
+
* that you can do something based on every ResultCell in a ResultRow. See that
|
|
247
|
+
* method for specific examples.
|
|
248
|
+
*
|
|
249
|
+
* @param cellId The Id of the ResultCell that the callback can operate on.
|
|
250
|
+
* @param cell The value of the ResultCell.
|
|
251
|
+
* @category Callback
|
|
252
|
+
*/
|
|
253
|
+
export type ResultCellCallback = (cellId: Id, cell: ResultCell) => void;
|
|
254
|
+
|
|
156
255
|
/**
|
|
157
256
|
* The ResultTableListener type describes a function that is used to listen to
|
|
158
|
-
* changes to a query's
|
|
257
|
+
* changes to a query's ResultTable.
|
|
159
258
|
*
|
|
160
259
|
* A ResultTableListener is provided when using the addResultTableListener
|
|
161
260
|
* method. See that method for specific examples.
|
|
162
261
|
*
|
|
163
262
|
* When called, a ResultTableListener is given a reference to the Queries
|
|
164
|
-
* object, the Id of the
|
|
165
|
-
* and a
|
|
166
|
-
* after the change.
|
|
263
|
+
* object, the Id of the ResultTable that changed (which is the same as the
|
|
264
|
+
* query Id), and a GetCellResultChange function that can be used to query
|
|
265
|
+
* ResultCell values before and after the change.
|
|
167
266
|
*
|
|
168
267
|
* @param queries A reference to the Queries object that changed.
|
|
169
|
-
* @param tableId The Id of the
|
|
170
|
-
*
|
|
171
|
-
*
|
|
268
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
269
|
+
* query Id.
|
|
270
|
+
* @param getCellChange A function that returns information about any
|
|
271
|
+
* ResultCell's changes.
|
|
172
272
|
* @category Listener
|
|
173
273
|
* @since v2.0.0
|
|
174
274
|
*/
|
|
175
275
|
export type ResultTableListener = (
|
|
176
276
|
queries: Queries,
|
|
177
277
|
tableId: Id,
|
|
178
|
-
getCellChange:
|
|
278
|
+
getCellChange: GetCellResultChange,
|
|
179
279
|
) => void;
|
|
180
280
|
|
|
181
281
|
/**
|
|
182
282
|
* The ResultRowIdsListener type describes a function that is used to listen to
|
|
183
|
-
* changes to the
|
|
283
|
+
* changes to the ResultRow Ids in a query's ResultTable.
|
|
184
284
|
*
|
|
185
285
|
* A ResultRowIdsListener is provided when using the addResultRowIdsListener
|
|
186
286
|
* method. See that method for specific examples.
|
|
187
287
|
*
|
|
188
288
|
* When called, a ResultRowIdsListener is given a reference to the Queries
|
|
189
|
-
* object, and the Id of the
|
|
190
|
-
* the query Id).
|
|
289
|
+
* object, and the Id of the ResultTable whose ResultRow Ids changed (which is
|
|
290
|
+
* the same as the query Id).
|
|
191
291
|
*
|
|
192
292
|
* @param queries A reference to the Queries object that changed.
|
|
193
|
-
* @param tableId The Id of the
|
|
293
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
294
|
+
* query Id.
|
|
194
295
|
* @category Listener
|
|
195
296
|
* @since v2.0.0
|
|
196
297
|
*/
|
|
@@ -198,26 +299,28 @@ export type ResultRowIdsListener = (queries: Queries, tableId: Id) => void;
|
|
|
198
299
|
|
|
199
300
|
/**
|
|
200
301
|
* The ResultSortedRowIdsListener type describes a function that is used to
|
|
201
|
-
* listen to changes to the sorted
|
|
302
|
+
* listen to changes to the sorted ResultRow Ids in a query's ResultTable.
|
|
202
303
|
*
|
|
203
304
|
* A ResultSortedRowIdsListener is provided when using the
|
|
204
305
|
* addResultSortedRowIdsListener method. See that method for specific examples.
|
|
205
306
|
*
|
|
206
307
|
* When called, a ResultSortedRowIdsListener is given a reference to the Queries
|
|
207
|
-
* object, the Id of the
|
|
208
|
-
* query Id), the
|
|
209
|
-
* and the offset and limit of the number of Ids returned,
|
|
210
|
-
* purposes. It also receives the sorted array of Ids itself, so
|
|
211
|
-
* use them in the listener without the additional cost of an
|
|
212
|
-
* getResultSortedRowIds.
|
|
308
|
+
* object, the Id of the ResultTable whose ResultRow Ids changed (which is the
|
|
309
|
+
* same as the query Id), the ResultCell Id being used to sort them, whether
|
|
310
|
+
* descending or not, and the offset and limit of the number of Ids returned,
|
|
311
|
+
* for pagination purposes. It also receives the sorted array of Ids itself, so
|
|
312
|
+
* that you can use them in the listener without the additional cost of an
|
|
313
|
+
* explicit call to getResultSortedRowIds.
|
|
213
314
|
*
|
|
214
315
|
* @param queries A reference to the Queries object that changed.
|
|
215
|
-
* @param tableId The Id of the
|
|
216
|
-
*
|
|
316
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
317
|
+
* query Id.
|
|
318
|
+
* @param cellId The Id of the ResultCell whose values were used for the
|
|
319
|
+
* sorting.
|
|
217
320
|
* @param descending Whether the sorting was in descending order.
|
|
218
|
-
* @param offset The number of
|
|
219
|
-
* @param limit The maximum number of
|
|
220
|
-
* @param sortedRowIds The sorted
|
|
321
|
+
* @param offset The number of ResultRow Ids skipped.
|
|
322
|
+
* @param limit The maximum number of ResultRow Ids returned.
|
|
323
|
+
* @param sortedRowIds The sorted ResultRow Ids themselves.
|
|
221
324
|
* @category Listener
|
|
222
325
|
* @since v2.0.0
|
|
223
326
|
*/
|
|
@@ -233,21 +336,22 @@ export type ResultSortedRowIdsListener = (
|
|
|
233
336
|
|
|
234
337
|
/**
|
|
235
338
|
* The ResultRowListener type describes a function that is used to listen to
|
|
236
|
-
* changes to a
|
|
339
|
+
* changes to a ResultRow in a query's ResultTable.
|
|
237
340
|
*
|
|
238
341
|
* A ResultRowListener is provided when using the addResultRowListener method.
|
|
239
342
|
* See that method for specific examples.
|
|
240
343
|
*
|
|
241
344
|
* When called, a ResultRowListener is given a reference to the Queries object,
|
|
242
|
-
* the Id of the
|
|
243
|
-
* of the
|
|
244
|
-
* query
|
|
345
|
+
* the Id of the ResultTable that changed (which is the same as the query Id),
|
|
346
|
+
* the Id of the ResultRow that changed, and a GetCellResultChange function that
|
|
347
|
+
* can be used to query ResultCell values before and after the change.
|
|
245
348
|
*
|
|
246
349
|
* @param queries A reference to the Queries object that changed.
|
|
247
|
-
* @param tableId The Id of the
|
|
248
|
-
*
|
|
249
|
-
* @param
|
|
250
|
-
*
|
|
350
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
351
|
+
* query Id.
|
|
352
|
+
* @param rowId The Id of the ResultRow that changed.
|
|
353
|
+
* @param getCellChange A function that returns information about any
|
|
354
|
+
* ResultCell's changes.
|
|
251
355
|
* @category Listener
|
|
252
356
|
* @since v2.0.0
|
|
253
357
|
*/
|
|
@@ -255,23 +359,24 @@ export type ResultRowListener = (
|
|
|
255
359
|
queries: Queries,
|
|
256
360
|
tableId: Id,
|
|
257
361
|
rowId: Id,
|
|
258
|
-
getCellChange:
|
|
362
|
+
getCellChange: GetCellResultChange,
|
|
259
363
|
) => void;
|
|
260
364
|
|
|
261
365
|
/**
|
|
262
366
|
* The ResultCellIdsListener type describes a function that is used to listen to
|
|
263
|
-
* changes to the
|
|
367
|
+
* changes to the ResultCell Ids in a ResultRow in a query's ResultTable.
|
|
264
368
|
*
|
|
265
369
|
* A ResultCellIdsListener is provided when using the addResultCellIdsListener
|
|
266
370
|
* method. See that method for specific examples.
|
|
267
371
|
*
|
|
268
372
|
* When called, a ResultCellIdsListener is given a reference to the Queries
|
|
269
|
-
* object, the Id of the
|
|
270
|
-
* and the Id of the
|
|
373
|
+
* object, the Id of the ResultTable that changed (which is the same as the
|
|
374
|
+
* query Id), and the Id of the ResultRow whose ResultCell Ids changed.
|
|
271
375
|
*
|
|
272
376
|
* @param queries A reference to the Queries object that changed.
|
|
273
|
-
* @param tableId The Id of the
|
|
274
|
-
*
|
|
377
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
378
|
+
* query Id.
|
|
379
|
+
* @param rowId The Id of the ResultRow that changed.
|
|
275
380
|
* @category Listener
|
|
276
381
|
* @since v2.0.0
|
|
277
382
|
*/
|
|
@@ -283,25 +388,27 @@ export type ResultCellIdsListener = (
|
|
|
283
388
|
|
|
284
389
|
/**
|
|
285
390
|
* The ResultCellListener type describes a function that is used to listen to
|
|
286
|
-
* changes to a
|
|
391
|
+
* changes to a ResultCell in a query's ResultTable.
|
|
287
392
|
*
|
|
288
393
|
* A ResultCellListener is provided when using the addResultCellListener method.
|
|
289
394
|
* See that method for specific examples.
|
|
290
395
|
*
|
|
291
396
|
* When called, a ResultCellListener is given a reference to the Queries object,
|
|
292
|
-
* the Id of the
|
|
293
|
-
* of the
|
|
294
|
-
* the new value of the
|
|
295
|
-
* function that can be used to query
|
|
397
|
+
* the Id of the ResultTable that changed (which is the same as the query Id),
|
|
398
|
+
* the Id of the ResultRow that changed, and the Id of ResultCell that changed.
|
|
399
|
+
* It is also given the new value of the ResultCell, the old value of the
|
|
400
|
+
* ResultCell, and a GetCellResultChange function that can be used to query
|
|
401
|
+
* ResultCell values before and after the change.
|
|
296
402
|
*
|
|
297
403
|
* @param queries A reference to the Queries object that changed.
|
|
298
|
-
* @param tableId The Id of the
|
|
299
|
-
*
|
|
300
|
-
* @param
|
|
301
|
-
* @param
|
|
302
|
-
* @param
|
|
303
|
-
* @param
|
|
304
|
-
*
|
|
404
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
405
|
+
* query Id.
|
|
406
|
+
* @param rowId The Id of the ResultRow that changed.
|
|
407
|
+
* @param cellId The Id of the ResultCell that changed.
|
|
408
|
+
* @param newCell The new value of the ResultCell that changed.
|
|
409
|
+
* @param oldCell The old value of the ResultCell that changed.
|
|
410
|
+
* @param getCellChange A function that returns information about any
|
|
411
|
+
* ResultCell's changes.
|
|
305
412
|
* @category Listener
|
|
306
413
|
* @since v2.0.0
|
|
307
414
|
*/
|
|
@@ -310,11 +417,50 @@ export type ResultCellListener = (
|
|
|
310
417
|
tableId: Id,
|
|
311
418
|
rowId: Id,
|
|
312
419
|
cellId: Id,
|
|
313
|
-
newCell:
|
|
314
|
-
oldCell:
|
|
315
|
-
getCellChange:
|
|
420
|
+
newCell: ResultCell,
|
|
421
|
+
oldCell: ResultCell,
|
|
422
|
+
getCellChange: GetCellResultChange,
|
|
316
423
|
) => void;
|
|
317
424
|
|
|
425
|
+
/**
|
|
426
|
+
* The GetCellResultChange type describes a function that returns information
|
|
427
|
+
* about any ResultCell's changes during a transaction.
|
|
428
|
+
*
|
|
429
|
+
* A GetCellResultChange function is provided to every listener when called due
|
|
430
|
+
* the Store changing. The listener can then fetch the previous value of a
|
|
431
|
+
* ResultCell before the current transaction, the new value after it, and a
|
|
432
|
+
* convenience flag that indicates that the value has changed.
|
|
433
|
+
*
|
|
434
|
+
* @param tableId The Id of the ResultTable to inspect.
|
|
435
|
+
* @param rowId The Id of the ResultRow to inspect.
|
|
436
|
+
* @param cellId The Id of the ResultCell to inspect.
|
|
437
|
+
* @returns A ResultCellChange array containing information about the
|
|
438
|
+
* ResultCell's changes.
|
|
439
|
+
* @category Listener
|
|
440
|
+
*/
|
|
441
|
+
export type GetCellResultChange = (
|
|
442
|
+
tableId: Id,
|
|
443
|
+
rowId: Id,
|
|
444
|
+
cellId: Id,
|
|
445
|
+
) => ResultCellChange;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* The ResultCellChange type describes a ResultCell's changes during a
|
|
449
|
+
* transaction.
|
|
450
|
+
*
|
|
451
|
+
* This is returned by the GetResultCellChange function that is provided to
|
|
452
|
+
* every listener when called. This array contains the previous value of a
|
|
453
|
+
* ResultCell before the current transaction, the new value after it, and a
|
|
454
|
+
* convenience flag that indicates that the value has changed.
|
|
455
|
+
*
|
|
456
|
+
* @category Listener
|
|
457
|
+
*/
|
|
458
|
+
export type ResultCellChange = [
|
|
459
|
+
changed: boolean,
|
|
460
|
+
oldCell: ResultCellOrUndefined,
|
|
461
|
+
newCell: ResultCellOrUndefined,
|
|
462
|
+
];
|
|
463
|
+
|
|
318
464
|
/**
|
|
319
465
|
* The QueriesListenerStats type describes the number of listeners registered
|
|
320
466
|
* with the Queries object, and can be used for debugging purposes.
|
|
@@ -361,18 +507,18 @@ export type QueriesListenerStats = {
|
|
|
361
507
|
*/
|
|
362
508
|
export type GetTableCell = {
|
|
363
509
|
/**
|
|
364
|
-
* When called with one parameter, this function will return the value of
|
|
365
|
-
* specified Cell from the query's
|
|
366
|
-
* filtered.
|
|
510
|
+
* When called with one parameter, this function will return the value of
|
|
511
|
+
* the specified Cell from the query's root Table for the Row being selected
|
|
512
|
+
* or filtered.
|
|
367
513
|
*
|
|
368
514
|
* @param cellId The Id of the Cell to fetch the value for.
|
|
369
515
|
* @returns A Cell value or `undefined`.
|
|
370
516
|
*/
|
|
371
517
|
(cellId: Id): CellOrUndefined;
|
|
372
518
|
/**
|
|
373
|
-
* When called with two parameters, this function will return the value of
|
|
374
|
-
* specified Cell from a Table that has been joined in the query, for
|
|
375
|
-
* being selected or filtered.
|
|
519
|
+
* When called with two parameters, this function will return the value of
|
|
520
|
+
* the specified Cell from a Table that has been joined in the query, for
|
|
521
|
+
* the Row being selected or filtered.
|
|
376
522
|
*
|
|
377
523
|
* @param joinedTableId The Id of the Table to fetch the value from. If the
|
|
378
524
|
* underlying Table was joined 'as' a different Id, that should instead be
|
|
@@ -483,7 +629,7 @@ export type GetTableCell = {
|
|
|
483
629
|
export type Select = {
|
|
484
630
|
/**
|
|
485
631
|
* Calling this function with one Id parameter will indicate that the query
|
|
486
|
-
* should select the value of the specified Cell from the query's
|
|
632
|
+
* should select the value of the specified Cell from the query's root Table.
|
|
487
633
|
*
|
|
488
634
|
* @param cellId The Id of the Cell to fetch the value for.
|
|
489
635
|
* @returns A SelectedAs object so that the selected Cell Id can be optionally
|
|
@@ -506,7 +652,7 @@ export type Select = {
|
|
|
506
652
|
/**
|
|
507
653
|
* Calling this function with one callback parameter will indicate that the
|
|
508
654
|
* query should select a calculated value, based on one or more Cell values in
|
|
509
|
-
* the
|
|
655
|
+
* the root Table or a joined Table, or on the root Table's Row Id.
|
|
510
656
|
*
|
|
511
657
|
* @param getCell A callback that takes a GetTableCell function and the main
|
|
512
658
|
* Table's Row Id. These can be used to programmatically create a calculated
|
|
@@ -515,9 +661,10 @@ export type Select = {
|
|
|
515
661
|
* aliased.
|
|
516
662
|
*/
|
|
517
663
|
(
|
|
518
|
-
getCell: (getTableCell: GetTableCell, rowId: Id) =>
|
|
664
|
+
getCell: (getTableCell: GetTableCell, rowId: Id) => ResultCellOrUndefined,
|
|
519
665
|
): SelectedAs;
|
|
520
666
|
};
|
|
667
|
+
|
|
521
668
|
/**
|
|
522
669
|
* The SelectedAs type describes an object returned from calling a Select
|
|
523
670
|
* function so that the selected Cell Id can be optionally aliased.
|
|
@@ -588,11 +735,11 @@ export type SelectedAs = {
|
|
|
588
735
|
* distant join Table.
|
|
589
736
|
*
|
|
590
737
|
* Because a Join clause is used to identify which unique Row Id of the joined
|
|
591
|
-
* Table will be joined to each Row of the
|
|
738
|
+
* Table will be joined to each Row of the root Table, queries follow the 'left
|
|
592
739
|
* join' semantics you may be familiar with from SQL. This means that an
|
|
593
740
|
* unfiltered query will only ever return the same number of Rows as the main
|
|
594
741
|
* Table being queried, and indeed the resulting table (assuming it has not been
|
|
595
|
-
* aggregated) will even preserve the
|
|
742
|
+
* aggregated) will even preserve the root Table's original Row Ids.
|
|
596
743
|
*
|
|
597
744
|
* @example
|
|
598
745
|
* This example shows a query that joins a single Table by using an Id present
|
|
@@ -630,7 +777,7 @@ export type SelectedAs = {
|
|
|
630
777
|
* This example shows a query that joins the same underlying Table twice, and
|
|
631
778
|
* aliases them (and the selected Cell Ids). Note the left-join semantics: Felix
|
|
632
779
|
* the cat was bought, but the seller was unknown. The record still exists in
|
|
633
|
-
* the
|
|
780
|
+
* the ResultTable.
|
|
634
781
|
*
|
|
635
782
|
* ```js
|
|
636
783
|
* const store = createStore()
|
|
@@ -663,7 +810,7 @@ export type SelectedAs = {
|
|
|
663
810
|
* ```
|
|
664
811
|
* @example
|
|
665
812
|
* This example shows a query that calculates the Id of the joined Table based
|
|
666
|
-
* from multiple values in the
|
|
813
|
+
* from multiple values in the root Table rather than a single Cell.
|
|
667
814
|
*
|
|
668
815
|
* ```js
|
|
669
816
|
* const store = createStore()
|
|
@@ -742,10 +889,10 @@ export type Join = {
|
|
|
742
889
|
/**
|
|
743
890
|
* Calling this function with two Id parameters will indicate that the join to
|
|
744
891
|
* a Row in an adjacent Table is made by finding its Id in a Cell of the
|
|
745
|
-
* query's
|
|
892
|
+
* query's root Table.
|
|
746
893
|
*
|
|
747
894
|
* @param joinedTableId The Id of the Table to join to.
|
|
748
|
-
* @param on The Id of the Cell in the
|
|
895
|
+
* @param on The Id of the Cell in the root Table that contains the joined
|
|
749
896
|
* Table's Row Id.
|
|
750
897
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
751
898
|
* aliased.
|
|
@@ -754,10 +901,10 @@ export type Join = {
|
|
|
754
901
|
/**
|
|
755
902
|
* Calling this function with two parameters (where the second is a function)
|
|
756
903
|
* will indicate that the join to a Row in an adjacent Table is made by
|
|
757
|
-
* calculating its Id from the Cells and the Row Id of the query's
|
|
904
|
+
* calculating its Id from the Cells and the Row Id of the query's root Table.
|
|
758
905
|
*
|
|
759
906
|
* @param joinedTableId The Id of the Table to join to.
|
|
760
|
-
* @param on A callback that takes a GetCell function and the
|
|
907
|
+
* @param on A callback that takes a GetCell function and the root Table's Row
|
|
761
908
|
* Id. These can be used to programmatically calculate the joined Table's Row
|
|
762
909
|
* Id.
|
|
763
910
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
@@ -803,10 +950,11 @@ export type Join = {
|
|
|
803
950
|
fromIntermediateJoinedTableId: Id,
|
|
804
951
|
on: (
|
|
805
952
|
getIntermediateJoinedCell: GetCell,
|
|
806
|
-
|
|
953
|
+
intermediateJoinedRowId: Id,
|
|
807
954
|
) => Id | undefined,
|
|
808
955
|
): JoinedAs;
|
|
809
956
|
};
|
|
957
|
+
|
|
810
958
|
/**
|
|
811
959
|
* The JoinedAs type describes an object returned from calling a Join function
|
|
812
960
|
* so that the joined Table Id can be optionally aliased.
|
|
@@ -815,6 +963,9 @@ export type Join = {
|
|
|
815
963
|
* create two joins to the same underlying Table, both _without_ aliases), only
|
|
816
964
|
* the latter of two will be used in the query.
|
|
817
965
|
*
|
|
966
|
+
* For the purposes of clarity, it's recommended to use an alias that does not
|
|
967
|
+
* collide with a real underlying Table (whether included in the query or not).
|
|
968
|
+
*
|
|
818
969
|
* @example
|
|
819
970
|
* This example shows a query that joins the same underlying Table twice, for
|
|
820
971
|
* different purposes. Both joins are aliased with the 'as' function to
|
|
@@ -852,17 +1003,22 @@ export type Join = {
|
|
|
852
1003
|
* @category Definition
|
|
853
1004
|
* @since v2.0.0
|
|
854
1005
|
*/
|
|
855
|
-
export type JoinedAs = {
|
|
1006
|
+
export type JoinedAs = {
|
|
1007
|
+
/**
|
|
1008
|
+
* A function that lets you specify an alias for the joined Table Id.
|
|
1009
|
+
*/
|
|
1010
|
+
as: (joinedTableId: Id) => void;
|
|
1011
|
+
};
|
|
856
1012
|
|
|
857
1013
|
/**
|
|
858
1014
|
* The Where type describes a function that lets you specify conditions to
|
|
859
|
-
* filter results, based on the underlying Cells of the
|
|
1015
|
+
* filter results, based on the underlying Cells of the root or joined Tables.
|
|
860
1016
|
*
|
|
861
1017
|
* The Where function is provided to the third `query` parameter of the
|
|
862
1018
|
* setQueryDefinition method.
|
|
863
1019
|
*
|
|
864
1020
|
* If you do not specify a Where clause, you should expect every non-empty Row
|
|
865
|
-
* of the
|
|
1021
|
+
* of the root Table to appear in the query's results.
|
|
866
1022
|
*
|
|
867
1023
|
* A Where condition has to be true for a Row to be included in the results.
|
|
868
1024
|
* Each Where class is additive, as though combined with a logical 'and'. If you
|
|
@@ -973,10 +1129,10 @@ export type JoinedAs = {as: (joinedTableId: Id) => void};
|
|
|
973
1129
|
export type Where = {
|
|
974
1130
|
/**
|
|
975
1131
|
* Calling this function with two parameters is used to include only those
|
|
976
|
-
* Rows for which a specified Cell in the query's
|
|
1132
|
+
* Rows for which a specified Cell in the query's root Table has a specified
|
|
977
1133
|
* value.
|
|
978
1134
|
*
|
|
979
|
-
* @param cellId The Id of the Cell in the query's
|
|
1135
|
+
* @param cellId The Id of the Cell in the query's root Table to test.
|
|
980
1136
|
* @param equals The value that the Cell has to have for the Row to be
|
|
981
1137
|
* included in the result.
|
|
982
1138
|
*/
|
|
@@ -1006,7 +1162,7 @@ export type Where = {
|
|
|
1006
1162
|
|
|
1007
1163
|
/**
|
|
1008
1164
|
* The Group type describes a function that lets you specify that the values of
|
|
1009
|
-
* a Cell in multiple
|
|
1165
|
+
* a Cell in multiple ResultRows should be aggregated together.
|
|
1010
1166
|
*
|
|
1011
1167
|
* The Group function is provided to the third `query` parameter of the
|
|
1012
1168
|
* setQueryDefinition method. When called, it should refer to a Cell Id (or
|
|
@@ -1046,7 +1202,7 @@ export type Where = {
|
|
|
1046
1202
|
* input values - for example, when a Row is added to the Table.
|
|
1047
1203
|
* @param aggregateRemove A function that can be used to optimize a custom
|
|
1048
1204
|
* Aggregate by providing a shortcut for when a single value is removed from the
|
|
1049
|
-
* input values - for example
|
|
1205
|
+
* input values - for example, when a Row is removed from the Table.
|
|
1050
1206
|
* @param aggregateReplace A function that can be used to optimize a custom
|
|
1051
1207
|
* Aggregate by providing a shortcut for when a single value in the input values
|
|
1052
1208
|
* is replaced with another - for example, when a Row is updated.
|
|
@@ -1183,6 +1339,7 @@ export type Group = (
|
|
|
1183
1339
|
aggregateRemove?: AggregateRemove,
|
|
1184
1340
|
aggregateReplace?: AggregateReplace,
|
|
1185
1341
|
) => GroupedAs;
|
|
1342
|
+
|
|
1186
1343
|
/**
|
|
1187
1344
|
* The GroupedAs type describes an object returned from calling a Group function
|
|
1188
1345
|
* so that the grouped Cell Id can be optionally aliased.
|
|
@@ -1221,7 +1378,12 @@ export type Group = (
|
|
|
1221
1378
|
* @category Definition
|
|
1222
1379
|
* @since v2.0.0
|
|
1223
1380
|
*/
|
|
1224
|
-
export type GroupedAs = {
|
|
1381
|
+
export type GroupedAs = {
|
|
1382
|
+
/**
|
|
1383
|
+
* A function that lets you specify an alias for the grouped Cell Id.
|
|
1384
|
+
*/
|
|
1385
|
+
as: (groupedCellId: Id) => void;
|
|
1386
|
+
};
|
|
1225
1387
|
|
|
1226
1388
|
/**
|
|
1227
1389
|
* The Having type describes a function that lets you specify conditions to
|
|
@@ -1314,7 +1476,7 @@ export type GroupedAs = {as: (groupedCellId: Id) => void};
|
|
|
1314
1476
|
export type Having = {
|
|
1315
1477
|
/**
|
|
1316
1478
|
* Calling this function with two parameters is used to include only those
|
|
1317
|
-
* Rows for which a specified Cell in the query's
|
|
1479
|
+
* Rows for which a specified Cell in the query's root Table has a specified
|
|
1318
1480
|
* value.
|
|
1319
1481
|
*
|
|
1320
1482
|
* @param selectedOrGroupedCellId The Id of the Cell in the query to test.
|
|
@@ -1429,16 +1591,17 @@ export type Having = {
|
|
|
1429
1591
|
* @category Queries
|
|
1430
1592
|
* @since v2.0.0
|
|
1431
1593
|
*/
|
|
1432
|
-
export interface Queries
|
|
1594
|
+
export interface Queries {
|
|
1595
|
+
//
|
|
1433
1596
|
/**
|
|
1434
1597
|
* The setQueryDefinition method lets you set the definition of a query.
|
|
1435
1598
|
*
|
|
1436
1599
|
* Every query definition is identified by a unique Id, and if you re-use an
|
|
1437
1600
|
* existing Id with this method, the previous definition is overwritten.
|
|
1438
1601
|
*
|
|
1439
|
-
* A query provides a tabular result formed from each Row within a
|
|
1440
|
-
* The definition must specify this
|
|
1441
|
-
*
|
|
1602
|
+
* A query provides a tabular result formed from each Row within a root Table.
|
|
1603
|
+
* The definition must specify this Table (by its Id) to be aggregated. Other
|
|
1604
|
+
* Tables can be joined to that using Join clauses.
|
|
1442
1605
|
*
|
|
1443
1606
|
* The third `query` parameter is a callback that you provide to define the
|
|
1444
1607
|
* query. That callback is provided with a `keywords` object that contains the
|
|
@@ -1454,7 +1617,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1454
1617
|
* filter results, based on the underlying Cells of the main or joined
|
|
1455
1618
|
* Tables.
|
|
1456
1619
|
* - The Group type describes a function that lets you specify that the values
|
|
1457
|
-
* of a Cell in multiple
|
|
1620
|
+
* of a Cell in multiple ResultRows should be aggregated together.
|
|
1458
1621
|
* - The Having type describes a function that lets you specify conditions to
|
|
1459
1622
|
* filter results, based on the grouped Cells resulting from a Group clause.
|
|
1460
1623
|
*
|
|
@@ -1465,7 +1628,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1465
1628
|
* addResultSortedRowIdsListener method to sort and paginate the results.
|
|
1466
1629
|
*
|
|
1467
1630
|
* @param queryId The Id of the query to define.
|
|
1468
|
-
* @param tableId The Id of the
|
|
1631
|
+
* @param tableId The Id of the root Table the query will be based on.
|
|
1469
1632
|
* @param query A callback which can take a `keywords` object and which uses
|
|
1470
1633
|
the functions it contains to define the query.
|
|
1471
1634
|
* @returns A reference to the Queries object.
|
|
@@ -1503,7 +1666,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1503
1666
|
group: Group;
|
|
1504
1667
|
having: Having;
|
|
1505
1668
|
}) => void,
|
|
1506
|
-
): Queries
|
|
1669
|
+
): Queries;
|
|
1507
1670
|
|
|
1508
1671
|
/**
|
|
1509
1672
|
* The delQueryDefinition method removes an existing query definition.
|
|
@@ -1536,7 +1699,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1536
1699
|
* @category Configuration
|
|
1537
1700
|
* @since v2.0.0
|
|
1538
1701
|
*/
|
|
1539
|
-
delQueryDefinition(queryId: Id): Queries
|
|
1702
|
+
delQueryDefinition(queryId: Id): Queries;
|
|
1540
1703
|
|
|
1541
1704
|
/**
|
|
1542
1705
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -1562,7 +1725,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1562
1725
|
* @category Getter
|
|
1563
1726
|
* @since v2.0.0
|
|
1564
1727
|
*/
|
|
1565
|
-
getStore(): Store
|
|
1728
|
+
getStore(): Store;
|
|
1566
1729
|
|
|
1567
1730
|
/**
|
|
1568
1731
|
* The getQueryIds method returns an array of the query Ids registered with
|
|
@@ -1690,7 +1853,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1690
1853
|
|
|
1691
1854
|
/**
|
|
1692
1855
|
* The getResultTable method returns an object containing the entire data of
|
|
1693
|
-
* the
|
|
1856
|
+
* the ResultTable of the given query.
|
|
1694
1857
|
*
|
|
1695
1858
|
* This has the same behavior as a Store's getTable method. For example, if
|
|
1696
1859
|
* the query Id is invalid, the method returns an empty object. Similarly, it
|
|
@@ -1699,13 +1862,13 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1699
1862
|
* themselves.
|
|
1700
1863
|
*
|
|
1701
1864
|
* @param queryId The Id of a query.
|
|
1702
|
-
* @returns An object containing the entire data of the
|
|
1865
|
+
* @returns An object containing the entire data of the ResultTable of the
|
|
1703
1866
|
* query.
|
|
1704
|
-
* @returns The result of the query, structured as a
|
|
1867
|
+
* @returns The result of the query, structured as a ResultTable.
|
|
1705
1868
|
* @example
|
|
1706
1869
|
* This example creates a Queries object, a single query definition, and then
|
|
1707
1870
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1708
|
-
*
|
|
1871
|
+
* ResultTable.
|
|
1709
1872
|
*
|
|
1710
1873
|
* ```js
|
|
1711
1874
|
* const store = createStore().setTable('pets', {
|
|
@@ -1732,11 +1895,11 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1732
1895
|
* @category Result
|
|
1733
1896
|
* @since v2.0.0
|
|
1734
1897
|
*/
|
|
1735
|
-
getResultTable(queryId: Id):
|
|
1898
|
+
getResultTable(queryId: Id): ResultTable;
|
|
1736
1899
|
|
|
1737
1900
|
/**
|
|
1738
|
-
* The getResultRowIds method returns the Ids of every
|
|
1739
|
-
* of the given query.
|
|
1901
|
+
* The getResultRowIds method returns the Ids of every ResultRow in the
|
|
1902
|
+
* ResultTable of the given query.
|
|
1740
1903
|
*
|
|
1741
1904
|
* This has the same behavior as a Store's getRowIds method. For example, if
|
|
1742
1905
|
* the query Id is invalid, the method returns an empty array. Similarly, it
|
|
@@ -1744,11 +1907,11 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1744
1907
|
* made to the list object are not made to the query results themselves.
|
|
1745
1908
|
*
|
|
1746
1909
|
* @param queryId The Id of a query.
|
|
1747
|
-
* @returns An array of the Ids of every
|
|
1910
|
+
* @returns An array of the Ids of every ResultRow in the result of the query.
|
|
1748
1911
|
* @example
|
|
1749
1912
|
* This example creates a Queries object, a single query definition, and then
|
|
1750
1913
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1751
|
-
*
|
|
1914
|
+
* ResultRow Ids.
|
|
1752
1915
|
*
|
|
1753
1916
|
* ```js
|
|
1754
1917
|
* const store = createStore().setTable('pets', {
|
|
@@ -1778,37 +1941,37 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1778
1941
|
getResultRowIds(queryId: Id): Ids;
|
|
1779
1942
|
|
|
1780
1943
|
/**
|
|
1781
|
-
* The getResultSortedRowIds method returns the Ids of every
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
1944
|
+
* The getResultSortedRowIds method returns the Ids of every ResultRow in the
|
|
1945
|
+
* ResultTable of the given query, sorted according to the values in a
|
|
1946
|
+
* specified ResultCell.
|
|
1784
1947
|
*
|
|
1785
1948
|
* This has the same behavior as a Store's getSortedRowIds method. For
|
|
1786
1949
|
* example, if the query Id is invalid, the method returns an empty array.
|
|
1787
1950
|
* Similarly, the sorting of the rows is alphanumeric, and you can indicate
|
|
1788
1951
|
* whether it should be in descending order. The `offset` and `limit`
|
|
1789
1952
|
* parameters are used to paginate results, but default to `0` and `undefined`
|
|
1790
|
-
* to return all available
|
|
1953
|
+
* to return all available ResultRow Ids if not specified.
|
|
1791
1954
|
*
|
|
1792
1955
|
* Note that every call to this method will perform the sorting afresh - there
|
|
1793
1956
|
* is no caching of the results - and so you are advised to memoize the
|
|
1794
|
-
* results yourself, especially when the
|
|
1795
|
-
* performant approach to tracking the sorted
|
|
1796
|
-
* the addResultSortedRowIdsListener method.
|
|
1957
|
+
* results yourself, especially when the ResultTable is large. For a
|
|
1958
|
+
* performant approach to tracking the sorted ResultRow Ids when they change,
|
|
1959
|
+
* use the addResultSortedRowIdsListener method.
|
|
1797
1960
|
*
|
|
1798
1961
|
* @param queryId The Id of a query.
|
|
1799
|
-
* @param cellId The Id of the
|
|
1800
|
-
* `undefined` to by sort the
|
|
1962
|
+
* @param cellId The Id of the ResultCell whose values are used for the
|
|
1963
|
+
* sorting, or `undefined` to by sort the ResultRow Id itself.
|
|
1801
1964
|
* @param descending Whether the sorting should be in descending order.
|
|
1802
|
-
* @param offset The number of
|
|
1803
|
-
* any.
|
|
1804
|
-
* @param limit The maximum number of
|
|
1805
|
-
* all.
|
|
1806
|
-
* @returns An array of the sorted Ids of every
|
|
1965
|
+
* @param offset The number of ResultRow Ids to skip for pagination purposes,
|
|
1966
|
+
* if any.
|
|
1967
|
+
* @param limit The maximum number of ResultRow Ids to return, or `undefined`
|
|
1968
|
+
* for all.
|
|
1969
|
+
* @returns An array of the sorted Ids of every ResultRow in the result of the
|
|
1807
1970
|
* query.
|
|
1808
1971
|
* @example
|
|
1809
1972
|
* This example creates a Queries object, a single query definition, and then
|
|
1810
1973
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1811
|
-
*
|
|
1974
|
+
* ResultRow Ids.
|
|
1812
1975
|
*
|
|
1813
1976
|
* ```js
|
|
1814
1977
|
* const store = createStore().setTable('pets', {
|
|
@@ -1845,22 +2008,22 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1845
2008
|
|
|
1846
2009
|
/**
|
|
1847
2010
|
* The getResultRow method returns an object containing the entire data of a
|
|
1848
|
-
* single
|
|
2011
|
+
* single ResultRow in the ResultTable of the given query.
|
|
1849
2012
|
*
|
|
1850
2013
|
* This has the same behavior as a Store's getRow method. For example, if the
|
|
1851
|
-
* query or
|
|
1852
|
-
* it returns a copy of, rather than a reference to the underlying
|
|
1853
|
-
* changes made to the returned object are not made to the query
|
|
1854
|
-
* themselves.
|
|
2014
|
+
* query or ResultRow Id is invalid, the method returns an empty object.
|
|
2015
|
+
* Similarly, it returns a copy of, rather than a reference to the underlying
|
|
2016
|
+
* data, so changes made to the returned object are not made to the query
|
|
2017
|
+
* results themselves.
|
|
1855
2018
|
*
|
|
1856
2019
|
* @param queryId The Id of a query.
|
|
1857
|
-
* @param rowId The Id of the
|
|
1858
|
-
* @returns An object containing the entire data of the
|
|
1859
|
-
*
|
|
2020
|
+
* @param rowId The Id of the ResultRow in the ResultTable.
|
|
2021
|
+
* @returns An object containing the entire data of the ResultRow in the
|
|
2022
|
+
* ResultTable of the query.
|
|
1860
2023
|
* @example
|
|
1861
2024
|
* This example creates a Queries object, a single query definition, and then
|
|
1862
|
-
* calls this method on it (as well as a non-existent
|
|
1863
|
-
*
|
|
2025
|
+
* calls this method on it (as well as a non-existent ResultRow Id) to get
|
|
2026
|
+
* the ResultRow.
|
|
1864
2027
|
*
|
|
1865
2028
|
* ```js
|
|
1866
2029
|
* const store = createStore().setTable('pets', {
|
|
@@ -1887,26 +2050,26 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1887
2050
|
* @category Result
|
|
1888
2051
|
* @since v2.0.0
|
|
1889
2052
|
*/
|
|
1890
|
-
getResultRow(queryId: Id, rowId: Id):
|
|
2053
|
+
getResultRow(queryId: Id, rowId: Id): ResultRow;
|
|
1891
2054
|
|
|
1892
2055
|
/**
|
|
1893
|
-
* The getResultCellIds method returns the Ids of every
|
|
1894
|
-
* in the
|
|
2056
|
+
* The getResultCellIds method returns the Ids of every ResultCell in a given
|
|
2057
|
+
* ResultRow, in the ResultTable of the given query.
|
|
1895
2058
|
*
|
|
1896
2059
|
* This has the same behavior as a Store's getCellIds method. For example, if
|
|
1897
|
-
* the query Id or
|
|
2060
|
+
* the query Id or ResultRow Id is invalid, the method returns an empty array.
|
|
1898
2061
|
* Similarly, it returns a copy of, rather than a reference to the list of
|
|
1899
2062
|
* Ids, so changes made to the list object are not made to the query results
|
|
1900
2063
|
* themselves.
|
|
1901
2064
|
*
|
|
1902
2065
|
* @param queryId The Id of a query.
|
|
1903
|
-
* @param rowId The Id of the
|
|
1904
|
-
* @returns An array of the Ids of every
|
|
1905
|
-
* query.
|
|
2066
|
+
* @param rowId The Id of the ResultRow in the ResultTable.
|
|
2067
|
+
* @returns An array of the Ids of every ResultCell in the ResultRow in the
|
|
2068
|
+
* result of the query.
|
|
1906
2069
|
* @example
|
|
1907
2070
|
* This example creates a Queries object, a single query definition, and then
|
|
1908
|
-
* calls this method on it (as well as a non-existent
|
|
1909
|
-
*
|
|
2071
|
+
* calls this method on it (as well as a non-existent ResultRow Id) to get the
|
|
2072
|
+
* ResultCell Ids.
|
|
1910
2073
|
*
|
|
1911
2074
|
* ```js
|
|
1912
2075
|
* const store = createStore().setTable('pets', {
|
|
@@ -1936,20 +2099,21 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1936
2099
|
getResultCellIds(queryId: Id, rowId: Id): Ids;
|
|
1937
2100
|
|
|
1938
2101
|
/**
|
|
1939
|
-
* The getResultCell method returns the value of a single
|
|
1940
|
-
* in the
|
|
2102
|
+
* The getResultCell method returns the value of a single ResultCell in a
|
|
2103
|
+
* given ResultRow, in the ResultTable of the given query.
|
|
1941
2104
|
*
|
|
1942
2105
|
* This has the same behavior as a Store's getCell method. For example, if the
|
|
1943
|
-
* query, or
|
|
2106
|
+
* query, or ResultRow, or ResultCell Id is invalid, the method returns
|
|
2107
|
+
* `undefined`.
|
|
1944
2108
|
*
|
|
1945
2109
|
* @param queryId The Id of a query.
|
|
1946
|
-
* @param rowId The Id of the
|
|
1947
|
-
* @param cellId The Id of the
|
|
1948
|
-
* @returns The value of the
|
|
2110
|
+
* @param rowId The Id of the ResultRow in the ResultTable.
|
|
2111
|
+
* @param cellId The Id of the ResultCell in the ResultRow.
|
|
2112
|
+
* @returns The value of the ResultCell, or `undefined`.
|
|
1949
2113
|
* @example
|
|
1950
2114
|
* This example creates a Queries object, a single query definition, and then
|
|
1951
|
-
* calls this method on it (as well as a non-existent
|
|
1952
|
-
*
|
|
2115
|
+
* calls this method on it (as well as a non-existent ResultCell Id) to get
|
|
2116
|
+
* the ResultCell.
|
|
1953
2117
|
*
|
|
1954
2118
|
* ```js
|
|
1955
2119
|
* const store = createStore().setTable('pets', {
|
|
@@ -1976,16 +2140,16 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1976
2140
|
* @category Result
|
|
1977
2141
|
* @since v2.0.0
|
|
1978
2142
|
*/
|
|
1979
|
-
getResultCell(queryId: Id, rowId: Id, cellId: Id):
|
|
2143
|
+
getResultCell(queryId: Id, rowId: Id, cellId: Id): ResultCellOrUndefined;
|
|
1980
2144
|
|
|
1981
2145
|
/**
|
|
1982
2146
|
* The hasResultTable method returns a boolean indicating whether a given
|
|
1983
|
-
*
|
|
2147
|
+
* ResultTable exists.
|
|
1984
2148
|
*
|
|
1985
2149
|
* @param queryId The Id of a possible query.
|
|
1986
|
-
* @returns Whether a
|
|
2150
|
+
* @returns Whether a ResultTable for that query Id exists.
|
|
1987
2151
|
* @example
|
|
1988
|
-
* This example shows two simple
|
|
2152
|
+
* This example shows two simple ResultTable existence checks.
|
|
1989
2153
|
*
|
|
1990
2154
|
* ```js
|
|
1991
2155
|
* const store = createStore().setTable('pets', {
|
|
@@ -2014,14 +2178,14 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2014
2178
|
hasResultTable(queryId: Id): boolean;
|
|
2015
2179
|
|
|
2016
2180
|
/**
|
|
2017
|
-
* The hasResultRow method returns a boolean indicating whether a given
|
|
2018
|
-
*
|
|
2181
|
+
* The hasResultRow method returns a boolean indicating whether a given
|
|
2182
|
+
* ResultRow exists.
|
|
2019
2183
|
*
|
|
2020
2184
|
* @param queryId The Id of a possible query.
|
|
2021
|
-
* @param rowId The Id of a possible
|
|
2022
|
-
* @returns Whether a
|
|
2185
|
+
* @param rowId The Id of a possible ResultRow.
|
|
2186
|
+
* @returns Whether a ResultRow for that Id exists.
|
|
2023
2187
|
* @example
|
|
2024
|
-
* This example shows two simple
|
|
2188
|
+
* This example shows two simple ResultRow existence checks.
|
|
2025
2189
|
*
|
|
2026
2190
|
* ```js
|
|
2027
2191
|
* const store = createStore().setTable('pets', {
|
|
@@ -2051,14 +2215,14 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2051
2215
|
|
|
2052
2216
|
/**
|
|
2053
2217
|
* The hasResultCell method returns a boolean indicating whether a given
|
|
2054
|
-
*
|
|
2218
|
+
* ResultCell exists.
|
|
2055
2219
|
*
|
|
2056
2220
|
* @param queryId The Id of a possible query.
|
|
2057
|
-
* @param rowId The Id of a possible
|
|
2058
|
-
* @param cellId The Id of a possible
|
|
2059
|
-
* @returns Whether a
|
|
2221
|
+
* @param rowId The Id of a possible ResultRow.
|
|
2222
|
+
* @param cellId The Id of a possible ResultCell.
|
|
2223
|
+
* @returns Whether a ResultCell for that Id exists.
|
|
2060
2224
|
* @example
|
|
2061
|
-
* This example shows two simple
|
|
2225
|
+
* This example shows two simple ResultRow existence checks.
|
|
2062
2226
|
*
|
|
2063
2227
|
* ```js
|
|
2064
2228
|
* const store = createStore().setTable('pets', {
|
|
@@ -2088,18 +2252,18 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2088
2252
|
|
|
2089
2253
|
/**
|
|
2090
2254
|
* The forEachResultTable method takes a function that it will then call for
|
|
2091
|
-
* each
|
|
2255
|
+
* each ResultTable in the Queries object.
|
|
2092
2256
|
*
|
|
2093
|
-
* This method is useful for iterating over all the
|
|
2257
|
+
* This method is useful for iterating over all the ResultTables of the
|
|
2094
2258
|
* queries in a functional style. The `tableCallback` parameter is a
|
|
2095
|
-
*
|
|
2096
|
-
*
|
|
2097
|
-
* of the
|
|
2259
|
+
* ResultTableCallback function that will be called with the Id of each
|
|
2260
|
+
* ResultTable, and with a function that can then be used to iterate over each
|
|
2261
|
+
* ResultRow of the ResultTable, should you wish.
|
|
2098
2262
|
*
|
|
2099
2263
|
* @param tableCallback The function that should be called for every query's
|
|
2100
|
-
*
|
|
2264
|
+
* ResultTable.
|
|
2101
2265
|
* @example
|
|
2102
|
-
* This example iterates over each query's
|
|
2266
|
+
* This example iterates over each query's ResultTable in a Queries object.
|
|
2103
2267
|
*
|
|
2104
2268
|
* ```js
|
|
2105
2269
|
* const store = createStore().setTable('pets', {
|
|
@@ -2131,23 +2295,23 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2131
2295
|
* @category Iterator
|
|
2132
2296
|
* @since v2.0.0
|
|
2133
2297
|
*/
|
|
2134
|
-
forEachResultTable(tableCallback:
|
|
2298
|
+
forEachResultTable(tableCallback: ResultTableCallback): void;
|
|
2135
2299
|
|
|
2136
2300
|
/**
|
|
2137
2301
|
* The forEachResultRow method takes a function that it will then call for
|
|
2138
|
-
* each
|
|
2302
|
+
* each ResultRow in the ResultTable of a query.
|
|
2139
2303
|
*
|
|
2140
|
-
* This method is useful for iterating over each
|
|
2141
|
-
* the query in a functional style. The `rowCallback` parameter is a
|
|
2142
|
-
*
|
|
2143
|
-
* and with a function that can then be used to iterate over each
|
|
2144
|
-
*
|
|
2304
|
+
* This method is useful for iterating over each ResultRow of the ResultTable
|
|
2305
|
+
* of the query in a functional style. The `rowCallback` parameter is a
|
|
2306
|
+
* ResultRowCallback function that will be called with the Id of each
|
|
2307
|
+
* ResultRow, and with a function that can then be used to iterate over each
|
|
2308
|
+
* ResultCell of the ResultRow, should you wish.
|
|
2145
2309
|
*
|
|
2146
2310
|
* @param queryId The Id of a query.
|
|
2147
|
-
* @param rowCallback The function that should be called for every
|
|
2148
|
-
* query's
|
|
2311
|
+
* @param rowCallback The function that should be called for every ResultRow
|
|
2312
|
+
* of the query's ResultTable.
|
|
2149
2313
|
* @example
|
|
2150
|
-
* This example iterates over each
|
|
2314
|
+
* This example iterates over each ResultRow in a query's ResultTable.
|
|
2151
2315
|
*
|
|
2152
2316
|
* ```js
|
|
2153
2317
|
* const store = createStore().setTable('pets', {
|
|
@@ -2177,22 +2341,23 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2177
2341
|
* @category Iterator
|
|
2178
2342
|
* @since v2.0.0
|
|
2179
2343
|
*/
|
|
2180
|
-
forEachResultRow(queryId: Id, rowCallback:
|
|
2344
|
+
forEachResultRow(queryId: Id, rowCallback: ResultRowCallback): void;
|
|
2181
2345
|
|
|
2182
2346
|
/**
|
|
2183
2347
|
* The forEachResultCell method takes a function that it will then call for
|
|
2184
|
-
* each
|
|
2348
|
+
* each ResultCell in the ResultRow of a query.
|
|
2185
2349
|
*
|
|
2186
|
-
* This method is useful for iterating over each
|
|
2187
|
-
* query in a functional style. The `cellCallback` parameter is a
|
|
2188
|
-
* function that will be called with the Id and value of
|
|
2350
|
+
* This method is useful for iterating over each ResultCell of the ResultRow
|
|
2351
|
+
* of the query in a functional style. The `cellCallback` parameter is a
|
|
2352
|
+
* ResultCellCallback function that will be called with the Id and value of
|
|
2353
|
+
* each ResultCell.
|
|
2189
2354
|
*
|
|
2190
2355
|
* @param queryId The Id of a query.
|
|
2191
|
-
* @param rowId The Id of a
|
|
2192
|
-
* @param cellCallback The function that should be called for every
|
|
2193
|
-
* the query's
|
|
2356
|
+
* @param rowId The Id of a ResultRow in the query's ResultTable.
|
|
2357
|
+
* @param cellCallback The function that should be called for every ResultCell
|
|
2358
|
+
* of the query's ResultRow.
|
|
2194
2359
|
* @example
|
|
2195
|
-
* This example iterates over each
|
|
2360
|
+
* This example iterates over each ResultCell in a query's ResultRow.
|
|
2196
2361
|
*
|
|
2197
2362
|
* ```js
|
|
2198
2363
|
* const store = createStore().setTable('pets', {
|
|
@@ -2220,28 +2385,32 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2220
2385
|
* @category Iterator
|
|
2221
2386
|
* @since v2.0.0
|
|
2222
2387
|
*/
|
|
2223
|
-
forEachResultCell(
|
|
2388
|
+
forEachResultCell(
|
|
2389
|
+
queryId: Id,
|
|
2390
|
+
rowId: Id,
|
|
2391
|
+
cellCallback: ResultCellCallback,
|
|
2392
|
+
): void;
|
|
2224
2393
|
|
|
2225
2394
|
/**
|
|
2226
2395
|
* The addResultTableListener method registers a listener function with the
|
|
2227
|
-
* Queries object that will be called whenever data in a
|
|
2396
|
+
* Queries object that will be called whenever data in a ResultTable changes.
|
|
2228
2397
|
*
|
|
2229
2398
|
* The provided listener is a ResultTableListener function, and will be called
|
|
2230
|
-
* with a reference to the Queries object, the Id of the
|
|
2231
|
-
* (which is also the query Id), and a
|
|
2232
|
-
* to inspect any changes that occurred.
|
|
2399
|
+
* with a reference to the Queries object, the Id of the ResultTable that
|
|
2400
|
+
* changed (which is also the query Id), and a GetCellResultChange function in
|
|
2401
|
+
* case you need to inspect any changes that occurred.
|
|
2233
2402
|
*
|
|
2234
|
-
* You can either listen to a single
|
|
2235
|
-
* the method's first parameter) or changes to any
|
|
2236
|
-
*
|
|
2403
|
+
* You can either listen to a single ResultTable (by specifying a query Id as
|
|
2404
|
+
* the method's first parameter) or changes to any ResultTable (by providing a
|
|
2405
|
+
* `null` wildcard).
|
|
2237
2406
|
*
|
|
2238
2407
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2239
2408
|
* @param listener The function that will be called whenever data in the
|
|
2240
|
-
* matching
|
|
2409
|
+
* matching ResultTable changes.
|
|
2241
2410
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2242
2411
|
* @example
|
|
2243
2412
|
* This example registers a listener that responds to any changes to a
|
|
2244
|
-
* specific
|
|
2413
|
+
* specific ResultTable.
|
|
2245
2414
|
*
|
|
2246
2415
|
* ```js
|
|
2247
2416
|
* const store = createStore().setTable('pets', {
|
|
@@ -2275,7 +2444,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2275
2444
|
* ```
|
|
2276
2445
|
* @example
|
|
2277
2446
|
* This example registers a listener that responds to any changes to any
|
|
2278
|
-
*
|
|
2447
|
+
* ResultTable.
|
|
2279
2448
|
*
|
|
2280
2449
|
* ```js
|
|
2281
2450
|
* const store = createStore().setTable('pets', {
|
|
@@ -2315,28 +2484,28 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2315
2484
|
|
|
2316
2485
|
/**
|
|
2317
2486
|
* The addResultRowIdsListener method registers a listener function with the
|
|
2318
|
-
* Queries object that will be called whenever the
|
|
2319
|
-
* change.
|
|
2487
|
+
* Queries object that will be called whenever the ResultRow Ids in a
|
|
2488
|
+
* ResultTable change.
|
|
2320
2489
|
*
|
|
2321
2490
|
* The provided listener is a ResultRowIdsListener function, and will be
|
|
2322
|
-
* called with a reference to the Queries object and the Id of the
|
|
2323
|
-
* changed (which is also the query Id).
|
|
2491
|
+
* called with a reference to the Queries object and the Id of the ResultTable
|
|
2492
|
+
* that changed (which is also the query Id).
|
|
2324
2493
|
*
|
|
2325
|
-
* By default, such a listener is only called when a
|
|
2326
|
-
* removed from, the
|
|
2327
|
-
*
|
|
2494
|
+
* By default, such a listener is only called when a ResultRow is added to, or
|
|
2495
|
+
* removed from, the ResultTable. To listen to all changes in the ResultTable,
|
|
2496
|
+
* use the addResultTableListener method.
|
|
2328
2497
|
*
|
|
2329
|
-
* You can either listen to a single
|
|
2330
|
-
* the method's first parameter) or changes to any
|
|
2331
|
-
*
|
|
2498
|
+
* You can either listen to a single ResultTable (by specifying a query Id as
|
|
2499
|
+
* the method's first parameter) or changes to any ResultTable (by providing a
|
|
2500
|
+
* `null` wildcard).
|
|
2332
2501
|
*
|
|
2333
2502
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2334
|
-
* @param listener The function that will be called whenever the
|
|
2335
|
-
* the
|
|
2503
|
+
* @param listener The function that will be called whenever the ResultRow Ids
|
|
2504
|
+
* in the ResultTable change.
|
|
2336
2505
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2337
2506
|
* @example
|
|
2338
|
-
* This example registers a listener that responds to any change to the
|
|
2339
|
-
* Ids of a specific
|
|
2507
|
+
* This example registers a listener that responds to any change to the
|
|
2508
|
+
* ResultRow Ids of a specific ResultTable.
|
|
2340
2509
|
*
|
|
2341
2510
|
* ```js
|
|
2342
2511
|
* const store = createStore().setTable('pets', {
|
|
@@ -2369,8 +2538,8 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2369
2538
|
* store.delListener(listenerId);
|
|
2370
2539
|
* ```
|
|
2371
2540
|
* @example
|
|
2372
|
-
* This example registers a listener that responds to any change to the
|
|
2373
|
-
* Ids of any
|
|
2541
|
+
* This example registers a listener that responds to any change to the
|
|
2542
|
+
* ResultRow Ids of any ResultTable.
|
|
2374
2543
|
*
|
|
2375
2544
|
* ```js
|
|
2376
2545
|
* const store = createStore().setTable('pets', {
|
|
@@ -2414,44 +2583,44 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2414
2583
|
/**
|
|
2415
2584
|
* The addResultSortedRowIdsListener method registers a listener function with
|
|
2416
2585
|
* the Queries object that will be called whenever sorted (and optionally,
|
|
2417
|
-
* paginated)
|
|
2586
|
+
* paginated) ResultRow Ids in a ResultTable change.
|
|
2418
2587
|
*
|
|
2419
2588
|
* The provided listener is a ResultSortedRowIdsListener function, and will be
|
|
2420
|
-
* called with a reference to the Queries object, the Id of the
|
|
2421
|
-
* whose
|
|
2422
|
-
* being used to sort them, whether descending or not, and the
|
|
2423
|
-
* limit of the number of Ids returned, for pagination purposes. It
|
|
2424
|
-
* receives the sorted array of Ids itself, so that you can use them in
|
|
2425
|
-
* listener without the additional cost of an explicit call to
|
|
2589
|
+
* called with a reference to the Queries object, the Id of the ResultTable
|
|
2590
|
+
* whose ResultRow Ids sorting changed (which is also the query Id), the
|
|
2591
|
+
* ResultCell Id being used to sort them, whether descending or not, and the
|
|
2592
|
+
* offset and limit of the number of Ids returned, for pagination purposes. It
|
|
2593
|
+
* also receives the sorted array of Ids itself, so that you can use them in
|
|
2594
|
+
* the listener without the additional cost of an explicit call to
|
|
2426
2595
|
* getResultSortedRowIds
|
|
2427
2596
|
*
|
|
2428
|
-
* Such a listener is called when a
|
|
2429
|
-
* value in the specified
|
|
2430
|
-
* enough to change the sorting of the
|
|
2597
|
+
* Such a listener is called when a ResultRow is added or removed, but also
|
|
2598
|
+
* when a value in the specified ResultCell (somewhere in the ResultTable) has
|
|
2599
|
+
* changed enough to change the sorting of the ResultRow Ids.
|
|
2431
2600
|
*
|
|
2432
2601
|
* Unlike most other listeners, you cannot provide wildcards (due to the cost
|
|
2433
2602
|
* of detecting changes to the sorting). You can only listen to a single
|
|
2434
|
-
* specified
|
|
2603
|
+
* specified ResultTable, sorted by a single specified ResultCell.
|
|
2435
2604
|
*
|
|
2436
2605
|
* The sorting of the rows is alphanumeric, and you can indicate whether it
|
|
2437
2606
|
* should be in descending order. The `offset` and `limit` parameters are used
|
|
2438
2607
|
* to paginate results, but default to `0` and `undefined` to return all
|
|
2439
|
-
* available
|
|
2608
|
+
* available ResultRow Ids if not specified.
|
|
2440
2609
|
*
|
|
2441
2610
|
* @param queryId The Id of the query to listen to.
|
|
2442
|
-
* @param cellId The Id of the
|
|
2443
|
-
* `undefined` to by sort the
|
|
2611
|
+
* @param cellId The Id of the ResultCell whose values are used for the
|
|
2612
|
+
* sorting, or `undefined` to by sort the ResultRow Id itself.
|
|
2444
2613
|
* @param descending Whether the sorting should be in descending order.
|
|
2445
|
-
* @param offset The number of
|
|
2446
|
-
* any.
|
|
2447
|
-
* @param limit The maximum number of
|
|
2448
|
-
* all.
|
|
2449
|
-
* @param listener The function that will be called whenever the sorted
|
|
2450
|
-
* Ids in the
|
|
2614
|
+
* @param offset The number of ResultRow Ids to skip for pagination purposes,
|
|
2615
|
+
* if any.
|
|
2616
|
+
* @param limit The maximum number of ResultRow Ids to return, or `undefined`
|
|
2617
|
+
* for all.
|
|
2618
|
+
* @param listener The function that will be called whenever the sorted
|
|
2619
|
+
* ResultRow Ids in the ResultTable change.
|
|
2451
2620
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2452
2621
|
* @example
|
|
2453
2622
|
* This example registers a listener that responds to any change to the sorted
|
|
2454
|
-
*
|
|
2623
|
+
* ResultRow Ids of a specific ResultTable.
|
|
2455
2624
|
*
|
|
2456
2625
|
* ```js
|
|
2457
2626
|
* const store = createStore().setTable('pets', {
|
|
@@ -2476,22 +2645,22 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2476
2645
|
* 0,
|
|
2477
2646
|
* undefined,
|
|
2478
2647
|
* (queries, tableId, cellId, descending, offset, limit, sortedRowIds) => {
|
|
2479
|
-
* console.log(`Sorted
|
|
2648
|
+
* console.log(`Sorted row Ids for dogColors result table changed`);
|
|
2480
2649
|
* console.log(sortedRowIds);
|
|
2481
2650
|
* // ^ cheaper than calling getResultSortedRowIds again
|
|
2482
2651
|
* },
|
|
2483
2652
|
* );
|
|
2484
2653
|
*
|
|
2485
2654
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'});
|
|
2486
|
-
* // -> 'Sorted
|
|
2655
|
+
* // -> 'Sorted row Ids for dogColors result table changed'
|
|
2487
2656
|
* // -> ['cujo', 'fido', 'rex']
|
|
2488
2657
|
*
|
|
2489
2658
|
* store.delListener(listenerId);
|
|
2490
2659
|
* ```
|
|
2491
2660
|
* @example
|
|
2492
2661
|
* This example registers a listener that responds to any change to the sorted
|
|
2493
|
-
*
|
|
2494
|
-
* since the `cellId` parameter is explicitly undefined.
|
|
2662
|
+
* ResultRow Ids of a specific ResultTable. The ResultRow Ids are sorted by
|
|
2663
|
+
* their own value, since the `cellId` parameter is explicitly undefined.
|
|
2495
2664
|
*
|
|
2496
2665
|
* ```js
|
|
2497
2666
|
* const store = createStore().setTable('pets', {
|
|
@@ -2518,14 +2687,14 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2518
2687
|
* 0,
|
|
2519
2688
|
* undefined,
|
|
2520
2689
|
* (queries, tableId, cellId, descending, offset, limit, sortedRowIds) => {
|
|
2521
|
-
* console.log(`Sorted
|
|
2690
|
+
* console.log(`Sorted row Ids for dogColors result table changed`);
|
|
2522
2691
|
* console.log(sortedRowIds);
|
|
2523
2692
|
* // ^ cheaper than calling getSortedRowIds again
|
|
2524
2693
|
* },
|
|
2525
2694
|
* );
|
|
2526
2695
|
*
|
|
2527
2696
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'});
|
|
2528
|
-
* // -> 'Sorted
|
|
2697
|
+
* // -> 'Sorted row Ids for dogColors result table changed'
|
|
2529
2698
|
* // -> ['cujo', 'fido', 'rex']
|
|
2530
2699
|
*
|
|
2531
2700
|
* store.delListener(listenerId);
|
|
@@ -2544,31 +2713,30 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2544
2713
|
|
|
2545
2714
|
/**
|
|
2546
2715
|
* The addResultRowListener method registers a listener function with the
|
|
2547
|
-
* Queries object that will be called whenever data in a
|
|
2716
|
+
* Queries object that will be called whenever data in a ResultRow changes.
|
|
2548
2717
|
*
|
|
2549
2718
|
* The provided listener is a ResultRowListener function, and will be called
|
|
2550
|
-
* with a reference to the Queries object, the Id of the
|
|
2551
|
-
* (which is also the query Id), and a
|
|
2552
|
-
* to inspect any changes that occurred.
|
|
2719
|
+
* with a reference to the Queries object, the Id of the ResultTable that
|
|
2720
|
+
* changed (which is also the query Id), and a GetCellResultChange function in
|
|
2721
|
+
* case you need to inspect any changes that occurred.
|
|
2553
2722
|
*
|
|
2554
|
-
* You can either listen to a single
|
|
2555
|
-
*
|
|
2556
|
-
* (by providing `null` wildcards).
|
|
2723
|
+
* You can either listen to a single ResultRow (by specifying a query Id and
|
|
2724
|
+
* ResultRow Id as the method's first two parameters) or changes to any
|
|
2725
|
+
* ResultRow (by providing `null` wildcards).
|
|
2557
2726
|
*
|
|
2558
2727
|
* Both, either, or neither of the `queryId` and `rowId` parameters can be
|
|
2559
|
-
* wildcarded with `null`. You can listen to a specific
|
|
2560
|
-
* specific query, any
|
|
2561
|
-
*
|
|
2728
|
+
* wildcarded with `null`. You can listen to a specific ResultRow in a
|
|
2729
|
+
* specific query, any ResultRow in a specific query, a specific ResultRow in
|
|
2730
|
+
* any query, or any ResultRow in any query.
|
|
2562
2731
|
*
|
|
2563
2732
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2564
|
-
* @param rowId The Id of the
|
|
2565
|
-
* wildcard.
|
|
2733
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
2566
2734
|
* @param listener The function that will be called whenever data in the
|
|
2567
|
-
* matching
|
|
2735
|
+
* matching ResultRow changes.
|
|
2568
2736
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2569
2737
|
* @example
|
|
2570
2738
|
* This example registers a listener that responds to any changes to a
|
|
2571
|
-
* specific
|
|
2739
|
+
* specific ResultRow.
|
|
2572
2740
|
*
|
|
2573
2741
|
* ```js
|
|
2574
2742
|
* const store = createStore().setTable('pets', {
|
|
@@ -2603,7 +2771,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2603
2771
|
* ```
|
|
2604
2772
|
* @example
|
|
2605
2773
|
* This example registers a listener that responds to any changes to any
|
|
2606
|
-
*
|
|
2774
|
+
* ResultRow.
|
|
2607
2775
|
*
|
|
2608
2776
|
* ```js
|
|
2609
2777
|
* const store = createStore().setTable('pets', {
|
|
@@ -2648,35 +2816,34 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2648
2816
|
|
|
2649
2817
|
/**
|
|
2650
2818
|
* The addResultCellIdsListener method registers a listener function with the
|
|
2651
|
-
* Queries object that will be called whenever the
|
|
2652
|
-
* change.
|
|
2819
|
+
* Queries object that will be called whenever the ResultCell Ids in a
|
|
2820
|
+
* ResultRow change.
|
|
2653
2821
|
*
|
|
2654
2822
|
* The provided listener is a ResultCellIdsListener function, and will be
|
|
2655
|
-
* called with a reference to the Queries object, the Id of the
|
|
2656
|
-
* is also the query Id), and the Id of the
|
|
2823
|
+
* called with a reference to the Queries object, the Id of the ResultTable
|
|
2824
|
+
* (which is also the query Id), and the Id of the ResultRow that changed.
|
|
2657
2825
|
*
|
|
2658
|
-
* Such a listener is only called when a
|
|
2659
|
-
* the
|
|
2826
|
+
* Such a listener is only called when a ResultCell is added to, or removed
|
|
2827
|
+
* from, the ResultRow. To listen to all changes in the ResultRow, use the
|
|
2660
2828
|
* addResultRowListener method.
|
|
2661
2829
|
*
|
|
2662
|
-
* You can either listen to a single
|
|
2663
|
-
*
|
|
2664
|
-
* providing `null` wildcards).
|
|
2830
|
+
* You can either listen to a single ResultRow (by specifying the query Id and
|
|
2831
|
+
* ResultRow Id as the method's first two parameters) or changes to any
|
|
2832
|
+
* ResultRow (by providing `null` wildcards).
|
|
2665
2833
|
*
|
|
2666
2834
|
* Both, either, or neither of the `queryId` and `rowId` parameters can be
|
|
2667
|
-
* wildcarded with `null`. You can listen to a specific
|
|
2668
|
-
* specific query, any
|
|
2669
|
-
*
|
|
2835
|
+
* wildcarded with `null`. You can listen to a specific ResultRow in a
|
|
2836
|
+
* specific query, any ResultRow in a specific query, a specific ResultRow in
|
|
2837
|
+
* any query, or any ResultRow in any query.
|
|
2670
2838
|
*
|
|
2671
2839
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2672
|
-
* @param rowId The Id of the
|
|
2673
|
-
*
|
|
2674
|
-
*
|
|
2675
|
-
* the result Row change.
|
|
2840
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
2841
|
+
* @param listener The function that will be called whenever the ResultCell
|
|
2842
|
+
* Ids in the ResultRow change.
|
|
2676
2843
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2677
2844
|
* @example
|
|
2678
|
-
* This example registers a listener that responds to any change to the
|
|
2679
|
-
* Ids of a specific
|
|
2845
|
+
* This example registers a listener that responds to any change to the
|
|
2846
|
+
* ResultCell Ids of a specific ResultRow.
|
|
2680
2847
|
*
|
|
2681
2848
|
* ```js
|
|
2682
2849
|
* const store = createStore().setTable('pets', {
|
|
@@ -2711,8 +2878,8 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2711
2878
|
* store.delListener(listenerId);
|
|
2712
2879
|
* ```
|
|
2713
2880
|
* @example
|
|
2714
|
-
* This example registers a listener that responds to any change to the
|
|
2715
|
-
* Ids of any
|
|
2881
|
+
* This example registers a listener that responds to any change to the
|
|
2882
|
+
* ResultCell Ids of any ResultRow.
|
|
2716
2883
|
*
|
|
2717
2884
|
* ```js
|
|
2718
2885
|
* const store = createStore().setTable('pets', {
|
|
@@ -2761,35 +2928,34 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2761
2928
|
|
|
2762
2929
|
/**
|
|
2763
2930
|
* The addResultCellListener method registers a listener function with the
|
|
2764
|
-
* Queries object that will be called whenever data in a
|
|
2931
|
+
* Queries object that will be called whenever data in a ResultCell changes.
|
|
2765
2932
|
*
|
|
2766
2933
|
* The provided listener is a ResultCellListener function, and will be called
|
|
2767
|
-
* with a reference to the Queries object, the Id of the
|
|
2768
|
-
* (which is also the query Id), the Id of the
|
|
2769
|
-
*
|
|
2770
|
-
*
|
|
2771
|
-
* occurred.
|
|
2934
|
+
* with a reference to the Queries object, the Id of the ResultTable that
|
|
2935
|
+
* changed (which is also the query Id), the Id of the ResultRow that changed,
|
|
2936
|
+
* the Id of the ResultCell that changed, the new ResultCell value, the old
|
|
2937
|
+
* ResultCell value, and a GetCellResultChange function in case you need to
|
|
2938
|
+
* inspect any changes that occurred.
|
|
2772
2939
|
*
|
|
2773
|
-
* You can either listen to a single
|
|
2774
|
-
* Id, and
|
|
2775
|
-
*
|
|
2940
|
+
* You can either listen to a single ResultRow (by specifying a query Id,
|
|
2941
|
+
* ResultRow Id, and ResultCell Id as the method's first three parameters) or
|
|
2942
|
+
* changes to any ResultCell (by providing `null` wildcards).
|
|
2776
2943
|
*
|
|
2777
2944
|
* All, some, or none of the `queryId`, `rowId`, and `cellId` parameters can
|
|
2778
|
-
* be wildcarded with `null`. You can listen to a specific
|
|
2779
|
-
*
|
|
2780
|
-
* for example - or every other combination of wildcards.
|
|
2945
|
+
* be wildcarded with `null`. You can listen to a specific ResultCell in a
|
|
2946
|
+
* specific ResultRow in a specific query, any ResultCell in any ResultRow in
|
|
2947
|
+
* any query, for example - or every other combination of wildcards.
|
|
2781
2948
|
*
|
|
2782
2949
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2783
|
-
* @param rowId The Id of the
|
|
2784
|
-
*
|
|
2785
|
-
* @param cellId The Id of the result Cell to listen to, or `null` as a
|
|
2950
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
2951
|
+
* @param cellId The Id of the ResultCell to listen to, or `null` as a
|
|
2786
2952
|
* wildcard.
|
|
2787
2953
|
* @param listener The function that will be called whenever data in the
|
|
2788
|
-
* matching
|
|
2954
|
+
* matching ResultCell changes.
|
|
2789
2955
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2790
2956
|
* @example
|
|
2791
2957
|
* This example registers a listener that responds to any changes to a
|
|
2792
|
-
* specific
|
|
2958
|
+
* specific ResultCell.
|
|
2793
2959
|
*
|
|
2794
2960
|
* ```js
|
|
2795
2961
|
* const store = createStore().setTable('pets', {
|
|
@@ -2829,7 +2995,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2829
2995
|
* ```
|
|
2830
2996
|
* @example
|
|
2831
2997
|
* This example registers a listener that responds to any changes to any
|
|
2832
|
-
*
|
|
2998
|
+
* ResultCell.
|
|
2833
2999
|
*
|
|
2834
3000
|
* ```js
|
|
2835
3001
|
* const store = createStore().setTable('pets', {
|
|
@@ -2921,7 +3087,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2921
3087
|
* @category Listener
|
|
2922
3088
|
* @since v2.0.0
|
|
2923
3089
|
*/
|
|
2924
|
-
delListener(listenerId: Id): Queries
|
|
3090
|
+
delListener(listenerId: Id): Queries;
|
|
2925
3091
|
|
|
2926
3092
|
/**
|
|
2927
3093
|
* The destroy method should be called when this Queries object is no longer
|
|
@@ -2988,6 +3154,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2988
3154
|
* @since v2.0.0
|
|
2989
3155
|
*/
|
|
2990
3156
|
getListenerStats(): QueriesListenerStats;
|
|
3157
|
+
//
|
|
2991
3158
|
}
|
|
2992
3159
|
|
|
2993
3160
|
/**
|
|
@@ -3023,6 +3190,4 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
3023
3190
|
* @category Creation
|
|
3024
3191
|
* @since v2.0.0
|
|
3025
3192
|
*/
|
|
3026
|
-
export function createQueries
|
|
3027
|
-
store: Store<Schemas>,
|
|
3028
|
-
): Queries<Schemas>;
|
|
3193
|
+
export function createQueries(store: Store): Queries;
|