tinybase 3.1.0-beta.4 → 3.1.0-beta.5
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/{cjs-es6 → types}/checkpoints.d.ts +11 -13
- package/lib/{debug → types}/indexes.d.ts +8 -16
- package/lib/{debug → types}/metrics.d.ts +47 -50
- package/lib/{cjs → types}/persisters.d.ts +24 -30
- package/lib/{cjs-es6 → types}/queries.d.ts +472 -309
- package/lib/{debug → types}/relationships.d.ts +9 -17
- package/lib/{cjs-es6 → types}/store.d.ts +176 -1084
- package/lib/types/tinybase.d.ts +14 -0
- package/lib/{cjs-es6 → types}/tools.d.ts +7 -12
- package/lib/{debug → types}/ui-react.d.ts +11 -5
- package/lib/{checkpoints.d.ts → types/with-schemas/checkpoints.d.ts} +9 -7
- package/lib/{cjs → types/with-schemas}/indexes.d.ts +31 -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 +54 -50
- package/lib/{debug → types/with-schemas}/persisters.d.ts +4 -4
- package/lib/{debug → types/with-schemas}/queries.d.ts +607 -346
- package/lib/{cjs → types/with-schemas}/relationships.d.ts +29 -20
- package/lib/{debug → types/with-schemas}/store.d.ts +386 -829
- package/lib/types/with-schemas/tinybase.d.ts +14 -0
- package/lib/{debug → types/with-schemas}/tools.d.ts +7 -10
- package/lib/{cjs-es6 → types/with-schemas}/ui-react.d.ts +817 -1314
- package/package.json +145 -29
- package/readme.md +3 -3
- 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,16 @@ export type Having = {
|
|
|
1429
1591
|
* @category Queries
|
|
1430
1592
|
* @since v2.0.0
|
|
1431
1593
|
*/
|
|
1432
|
-
export interface Queries
|
|
1594
|
+
export interface Queries {
|
|
1433
1595
|
/**
|
|
1434
1596
|
* The setQueryDefinition method lets you set the definition of a query.
|
|
1435
1597
|
*
|
|
1436
1598
|
* Every query definition is identified by a unique Id, and if you re-use an
|
|
1437
1599
|
* existing Id with this method, the previous definition is overwritten.
|
|
1438
1600
|
*
|
|
1439
|
-
* A query provides a tabular result formed from each Row within a
|
|
1440
|
-
* The definition must specify this
|
|
1441
|
-
*
|
|
1601
|
+
* A query provides a tabular result formed from each Row within a root Table.
|
|
1602
|
+
* The definition must specify this Table (by its Id) to be aggregated. Other
|
|
1603
|
+
* Tables can be joined to that using Join clauses.
|
|
1442
1604
|
*
|
|
1443
1605
|
* The third `query` parameter is a callback that you provide to define the
|
|
1444
1606
|
* query. That callback is provided with a `keywords` object that contains the
|
|
@@ -1454,7 +1616,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1454
1616
|
* filter results, based on the underlying Cells of the main or joined
|
|
1455
1617
|
* Tables.
|
|
1456
1618
|
* - The Group type describes a function that lets you specify that the values
|
|
1457
|
-
* of a Cell in multiple
|
|
1619
|
+
* of a Cell in multiple ResultRows should be aggregated together.
|
|
1458
1620
|
* - The Having type describes a function that lets you specify conditions to
|
|
1459
1621
|
* filter results, based on the grouped Cells resulting from a Group clause.
|
|
1460
1622
|
*
|
|
@@ -1465,7 +1627,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1465
1627
|
* addResultSortedRowIdsListener method to sort and paginate the results.
|
|
1466
1628
|
*
|
|
1467
1629
|
* @param queryId The Id of the query to define.
|
|
1468
|
-
* @param tableId The Id of the
|
|
1630
|
+
* @param tableId The Id of the root Table the query will be based on.
|
|
1469
1631
|
* @param query A callback which can take a `keywords` object and which uses
|
|
1470
1632
|
the functions it contains to define the query.
|
|
1471
1633
|
* @returns A reference to the Queries object.
|
|
@@ -1503,7 +1665,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1503
1665
|
group: Group;
|
|
1504
1666
|
having: Having;
|
|
1505
1667
|
}) => void,
|
|
1506
|
-
): Queries
|
|
1668
|
+
): Queries;
|
|
1507
1669
|
|
|
1508
1670
|
/**
|
|
1509
1671
|
* The delQueryDefinition method removes an existing query definition.
|
|
@@ -1536,7 +1698,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1536
1698
|
* @category Configuration
|
|
1537
1699
|
* @since v2.0.0
|
|
1538
1700
|
*/
|
|
1539
|
-
delQueryDefinition(queryId: Id): Queries
|
|
1701
|
+
delQueryDefinition(queryId: Id): Queries;
|
|
1540
1702
|
|
|
1541
1703
|
/**
|
|
1542
1704
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -1562,7 +1724,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1562
1724
|
* @category Getter
|
|
1563
1725
|
* @since v2.0.0
|
|
1564
1726
|
*/
|
|
1565
|
-
getStore(): Store
|
|
1727
|
+
getStore(): Store;
|
|
1566
1728
|
|
|
1567
1729
|
/**
|
|
1568
1730
|
* The getQueryIds method returns an array of the query Ids registered with
|
|
@@ -1690,7 +1852,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1690
1852
|
|
|
1691
1853
|
/**
|
|
1692
1854
|
* The getResultTable method returns an object containing the entire data of
|
|
1693
|
-
* the
|
|
1855
|
+
* the ResultTable of the given query.
|
|
1694
1856
|
*
|
|
1695
1857
|
* This has the same behavior as a Store's getTable method. For example, if
|
|
1696
1858
|
* the query Id is invalid, the method returns an empty object. Similarly, it
|
|
@@ -1699,13 +1861,13 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1699
1861
|
* themselves.
|
|
1700
1862
|
*
|
|
1701
1863
|
* @param queryId The Id of a query.
|
|
1702
|
-
* @returns An object containing the entire data of the
|
|
1864
|
+
* @returns An object containing the entire data of the ResultTable of the
|
|
1703
1865
|
* query.
|
|
1704
|
-
* @returns The result of the query, structured as a
|
|
1866
|
+
* @returns The result of the query, structured as a ResultTable.
|
|
1705
1867
|
* @example
|
|
1706
1868
|
* This example creates a Queries object, a single query definition, and then
|
|
1707
1869
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1708
|
-
*
|
|
1870
|
+
* ResultTable.
|
|
1709
1871
|
*
|
|
1710
1872
|
* ```js
|
|
1711
1873
|
* const store = createStore().setTable('pets', {
|
|
@@ -1732,11 +1894,11 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1732
1894
|
* @category Result
|
|
1733
1895
|
* @since v2.0.0
|
|
1734
1896
|
*/
|
|
1735
|
-
getResultTable(queryId: Id):
|
|
1897
|
+
getResultTable(queryId: Id): ResultTable;
|
|
1736
1898
|
|
|
1737
1899
|
/**
|
|
1738
|
-
* The getResultRowIds method returns the Ids of every
|
|
1739
|
-
* of the given query.
|
|
1900
|
+
* The getResultRowIds method returns the Ids of every ResultRow in the
|
|
1901
|
+
* ResultTable of the given query.
|
|
1740
1902
|
*
|
|
1741
1903
|
* This has the same behavior as a Store's getRowIds method. For example, if
|
|
1742
1904
|
* the query Id is invalid, the method returns an empty array. Similarly, it
|
|
@@ -1744,11 +1906,11 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1744
1906
|
* made to the list object are not made to the query results themselves.
|
|
1745
1907
|
*
|
|
1746
1908
|
* @param queryId The Id of a query.
|
|
1747
|
-
* @returns An array of the Ids of every
|
|
1909
|
+
* @returns An array of the Ids of every ResultRow in the result of the query.
|
|
1748
1910
|
* @example
|
|
1749
1911
|
* This example creates a Queries object, a single query definition, and then
|
|
1750
1912
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1751
|
-
*
|
|
1913
|
+
* ResultRow Ids.
|
|
1752
1914
|
*
|
|
1753
1915
|
* ```js
|
|
1754
1916
|
* const store = createStore().setTable('pets', {
|
|
@@ -1778,37 +1940,37 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1778
1940
|
getResultRowIds(queryId: Id): Ids;
|
|
1779
1941
|
|
|
1780
1942
|
/**
|
|
1781
|
-
* The getResultSortedRowIds method returns the Ids of every
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
1943
|
+
* The getResultSortedRowIds method returns the Ids of every ResultRow in the
|
|
1944
|
+
* ResultTable of the given query, sorted according to the values in a
|
|
1945
|
+
* specified ResultCell.
|
|
1784
1946
|
*
|
|
1785
1947
|
* This has the same behavior as a Store's getSortedRowIds method. For
|
|
1786
1948
|
* example, if the query Id is invalid, the method returns an empty array.
|
|
1787
1949
|
* Similarly, the sorting of the rows is alphanumeric, and you can indicate
|
|
1788
1950
|
* whether it should be in descending order. The `offset` and `limit`
|
|
1789
1951
|
* parameters are used to paginate results, but default to `0` and `undefined`
|
|
1790
|
-
* to return all available
|
|
1952
|
+
* to return all available ResultRow Ids if not specified.
|
|
1791
1953
|
*
|
|
1792
1954
|
* Note that every call to this method will perform the sorting afresh - there
|
|
1793
1955
|
* 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.
|
|
1956
|
+
* results yourself, especially when the ResultTable is large. For a
|
|
1957
|
+
* performant approach to tracking the sorted ResultRow Ids when they change,
|
|
1958
|
+
* use the addResultSortedRowIdsListener method.
|
|
1797
1959
|
*
|
|
1798
1960
|
* @param queryId The Id of a query.
|
|
1799
|
-
* @param cellId The Id of the
|
|
1800
|
-
* `undefined` to by sort the
|
|
1961
|
+
* @param cellId The Id of the ResultCell whose values are used for the
|
|
1962
|
+
* sorting, or `undefined` to by sort the ResultRow Id itself.
|
|
1801
1963
|
* @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
|
|
1964
|
+
* @param offset The number of ResultRow Ids to skip for pagination purposes,
|
|
1965
|
+
* if any.
|
|
1966
|
+
* @param limit The maximum number of ResultRow Ids to return, or `undefined`
|
|
1967
|
+
* for all.
|
|
1968
|
+
* @returns An array of the sorted Ids of every ResultRow in the result of the
|
|
1807
1969
|
* query.
|
|
1808
1970
|
* @example
|
|
1809
1971
|
* This example creates a Queries object, a single query definition, and then
|
|
1810
1972
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1811
|
-
*
|
|
1973
|
+
* ResultRow Ids.
|
|
1812
1974
|
*
|
|
1813
1975
|
* ```js
|
|
1814
1976
|
* const store = createStore().setTable('pets', {
|
|
@@ -1845,22 +2007,22 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1845
2007
|
|
|
1846
2008
|
/**
|
|
1847
2009
|
* The getResultRow method returns an object containing the entire data of a
|
|
1848
|
-
* single
|
|
2010
|
+
* single ResultRow in the ResultTable of the given query.
|
|
1849
2011
|
*
|
|
1850
2012
|
* 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.
|
|
2013
|
+
* query or ResultRow Id is invalid, the method returns an empty object.
|
|
2014
|
+
* Similarly, it returns a copy of, rather than a reference to the underlying
|
|
2015
|
+
* data, so changes made to the returned object are not made to the query
|
|
2016
|
+
* results themselves.
|
|
1855
2017
|
*
|
|
1856
2018
|
* @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
|
-
*
|
|
2019
|
+
* @param rowId The Id of the ResultRow in the ResultTable.
|
|
2020
|
+
* @returns An object containing the entire data of the ResultRow in the
|
|
2021
|
+
* ResultTable of the query.
|
|
1860
2022
|
* @example
|
|
1861
2023
|
* 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
|
-
*
|
|
2024
|
+
* calls this method on it (as well as a non-existent ResultRow Id) to get
|
|
2025
|
+
* the ResultRow.
|
|
1864
2026
|
*
|
|
1865
2027
|
* ```js
|
|
1866
2028
|
* const store = createStore().setTable('pets', {
|
|
@@ -1887,26 +2049,26 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1887
2049
|
* @category Result
|
|
1888
2050
|
* @since v2.0.0
|
|
1889
2051
|
*/
|
|
1890
|
-
getResultRow(queryId: Id, rowId: Id):
|
|
2052
|
+
getResultRow(queryId: Id, rowId: Id): ResultRow;
|
|
1891
2053
|
|
|
1892
2054
|
/**
|
|
1893
|
-
* The getResultCellIds method returns the Ids of every
|
|
1894
|
-
* in the
|
|
2055
|
+
* The getResultCellIds method returns the Ids of every ResultCell in a given
|
|
2056
|
+
* ResultRow, in the ResultTable of the given query.
|
|
1895
2057
|
*
|
|
1896
2058
|
* This has the same behavior as a Store's getCellIds method. For example, if
|
|
1897
|
-
* the query Id or
|
|
2059
|
+
* the query Id or ResultRow Id is invalid, the method returns an empty array.
|
|
1898
2060
|
* Similarly, it returns a copy of, rather than a reference to the list of
|
|
1899
2061
|
* Ids, so changes made to the list object are not made to the query results
|
|
1900
2062
|
* themselves.
|
|
1901
2063
|
*
|
|
1902
2064
|
* @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.
|
|
2065
|
+
* @param rowId The Id of the ResultRow in the ResultTable.
|
|
2066
|
+
* @returns An array of the Ids of every ResultCell in the ResultRow in the
|
|
2067
|
+
* result of the query.
|
|
1906
2068
|
* @example
|
|
1907
2069
|
* 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
|
-
*
|
|
2070
|
+
* calls this method on it (as well as a non-existent ResultRow Id) to get the
|
|
2071
|
+
* ResultCell Ids.
|
|
1910
2072
|
*
|
|
1911
2073
|
* ```js
|
|
1912
2074
|
* const store = createStore().setTable('pets', {
|
|
@@ -1936,20 +2098,21 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1936
2098
|
getResultCellIds(queryId: Id, rowId: Id): Ids;
|
|
1937
2099
|
|
|
1938
2100
|
/**
|
|
1939
|
-
* The getResultCell method returns the value of a single
|
|
1940
|
-
* in the
|
|
2101
|
+
* The getResultCell method returns the value of a single ResultCell in a
|
|
2102
|
+
* given ResultRow, in the ResultTable of the given query.
|
|
1941
2103
|
*
|
|
1942
2104
|
* This has the same behavior as a Store's getCell method. For example, if the
|
|
1943
|
-
* query, or
|
|
2105
|
+
* query, or ResultRow, or ResultCell Id is invalid, the method returns
|
|
2106
|
+
* `undefined`.
|
|
1944
2107
|
*
|
|
1945
2108
|
* @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
|
|
2109
|
+
* @param rowId The Id of the ResultRow in the ResultTable.
|
|
2110
|
+
* @param cellId The Id of the ResultCell in the ResultRow.
|
|
2111
|
+
* @returns The value of the ResultCell, or `undefined`.
|
|
1949
2112
|
* @example
|
|
1950
2113
|
* 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
|
-
*
|
|
2114
|
+
* calls this method on it (as well as a non-existent ResultCell Id) to get
|
|
2115
|
+
* the ResultCell.
|
|
1953
2116
|
*
|
|
1954
2117
|
* ```js
|
|
1955
2118
|
* const store = createStore().setTable('pets', {
|
|
@@ -1976,16 +2139,16 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1976
2139
|
* @category Result
|
|
1977
2140
|
* @since v2.0.0
|
|
1978
2141
|
*/
|
|
1979
|
-
getResultCell(queryId: Id, rowId: Id, cellId: Id):
|
|
2142
|
+
getResultCell(queryId: Id, rowId: Id, cellId: Id): ResultCellOrUndefined;
|
|
1980
2143
|
|
|
1981
2144
|
/**
|
|
1982
2145
|
* The hasResultTable method returns a boolean indicating whether a given
|
|
1983
|
-
*
|
|
2146
|
+
* ResultTable exists.
|
|
1984
2147
|
*
|
|
1985
2148
|
* @param queryId The Id of a possible query.
|
|
1986
|
-
* @returns Whether a
|
|
2149
|
+
* @returns Whether a ResultTable for that query Id exists.
|
|
1987
2150
|
* @example
|
|
1988
|
-
* This example shows two simple
|
|
2151
|
+
* This example shows two simple ResultTable existence checks.
|
|
1989
2152
|
*
|
|
1990
2153
|
* ```js
|
|
1991
2154
|
* const store = createStore().setTable('pets', {
|
|
@@ -2014,14 +2177,14 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2014
2177
|
hasResultTable(queryId: Id): boolean;
|
|
2015
2178
|
|
|
2016
2179
|
/**
|
|
2017
|
-
* The hasResultRow method returns a boolean indicating whether a given
|
|
2018
|
-
*
|
|
2180
|
+
* The hasResultRow method returns a boolean indicating whether a given
|
|
2181
|
+
* ResultRow exists.
|
|
2019
2182
|
*
|
|
2020
2183
|
* @param queryId The Id of a possible query.
|
|
2021
|
-
* @param rowId The Id of a possible
|
|
2022
|
-
* @returns Whether a
|
|
2184
|
+
* @param rowId The Id of a possible ResultRow.
|
|
2185
|
+
* @returns Whether a ResultRow for that Id exists.
|
|
2023
2186
|
* @example
|
|
2024
|
-
* This example shows two simple
|
|
2187
|
+
* This example shows two simple ResultRow existence checks.
|
|
2025
2188
|
*
|
|
2026
2189
|
* ```js
|
|
2027
2190
|
* const store = createStore().setTable('pets', {
|
|
@@ -2051,14 +2214,14 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2051
2214
|
|
|
2052
2215
|
/**
|
|
2053
2216
|
* The hasResultCell method returns a boolean indicating whether a given
|
|
2054
|
-
*
|
|
2217
|
+
* ResultCell exists.
|
|
2055
2218
|
*
|
|
2056
2219
|
* @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
|
|
2220
|
+
* @param rowId The Id of a possible ResultRow.
|
|
2221
|
+
* @param cellId The Id of a possible ResultCell.
|
|
2222
|
+
* @returns Whether a ResultCell for that Id exists.
|
|
2060
2223
|
* @example
|
|
2061
|
-
* This example shows two simple
|
|
2224
|
+
* This example shows two simple ResultRow existence checks.
|
|
2062
2225
|
*
|
|
2063
2226
|
* ```js
|
|
2064
2227
|
* const store = createStore().setTable('pets', {
|
|
@@ -2088,18 +2251,18 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2088
2251
|
|
|
2089
2252
|
/**
|
|
2090
2253
|
* The forEachResultTable method takes a function that it will then call for
|
|
2091
|
-
* each
|
|
2254
|
+
* each ResultTable in the Queries object.
|
|
2092
2255
|
*
|
|
2093
|
-
* This method is useful for iterating over all the
|
|
2256
|
+
* This method is useful for iterating over all the ResultTables of the
|
|
2094
2257
|
* queries in a functional style. The `tableCallback` parameter is a
|
|
2095
|
-
*
|
|
2096
|
-
*
|
|
2097
|
-
* of the
|
|
2258
|
+
* ResultTableCallback function that will be called with the Id of each
|
|
2259
|
+
* ResultTable, and with a function that can then be used to iterate over each
|
|
2260
|
+
* ResultRow of the ResultTable, should you wish.
|
|
2098
2261
|
*
|
|
2099
2262
|
* @param tableCallback The function that should be called for every query's
|
|
2100
|
-
*
|
|
2263
|
+
* ResultTable.
|
|
2101
2264
|
* @example
|
|
2102
|
-
* This example iterates over each query's
|
|
2265
|
+
* This example iterates over each query's ResultTable in a Queries object.
|
|
2103
2266
|
*
|
|
2104
2267
|
* ```js
|
|
2105
2268
|
* const store = createStore().setTable('pets', {
|
|
@@ -2131,23 +2294,23 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2131
2294
|
* @category Iterator
|
|
2132
2295
|
* @since v2.0.0
|
|
2133
2296
|
*/
|
|
2134
|
-
forEachResultTable(tableCallback:
|
|
2297
|
+
forEachResultTable(tableCallback: ResultTableCallback): void;
|
|
2135
2298
|
|
|
2136
2299
|
/**
|
|
2137
2300
|
* The forEachResultRow method takes a function that it will then call for
|
|
2138
|
-
* each
|
|
2301
|
+
* each ResultRow in the ResultTable of a query.
|
|
2139
2302
|
*
|
|
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
|
-
*
|
|
2303
|
+
* This method is useful for iterating over each ResultRow of the ResultTable
|
|
2304
|
+
* of the query in a functional style. The `rowCallback` parameter is a
|
|
2305
|
+
* ResultRowCallback function that will be called with the Id of each
|
|
2306
|
+
* ResultRow, and with a function that can then be used to iterate over each
|
|
2307
|
+
* ResultCell of the ResultRow, should you wish.
|
|
2145
2308
|
*
|
|
2146
2309
|
* @param queryId The Id of a query.
|
|
2147
|
-
* @param rowCallback The function that should be called for every
|
|
2148
|
-
* query's
|
|
2310
|
+
* @param rowCallback The function that should be called for every ResultRow
|
|
2311
|
+
* of the query's ResultTable.
|
|
2149
2312
|
* @example
|
|
2150
|
-
* This example iterates over each
|
|
2313
|
+
* This example iterates over each ResultRow in a query's ResultTable.
|
|
2151
2314
|
*
|
|
2152
2315
|
* ```js
|
|
2153
2316
|
* const store = createStore().setTable('pets', {
|
|
@@ -2177,22 +2340,23 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2177
2340
|
* @category Iterator
|
|
2178
2341
|
* @since v2.0.0
|
|
2179
2342
|
*/
|
|
2180
|
-
forEachResultRow(queryId: Id, rowCallback:
|
|
2343
|
+
forEachResultRow(queryId: Id, rowCallback: ResultRowCallback): void;
|
|
2181
2344
|
|
|
2182
2345
|
/**
|
|
2183
2346
|
* The forEachResultCell method takes a function that it will then call for
|
|
2184
|
-
* each
|
|
2347
|
+
* each ResultCell in the ResultRow of a query.
|
|
2185
2348
|
*
|
|
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
|
|
2349
|
+
* This method is useful for iterating over each ResultCell of the ResultRow
|
|
2350
|
+
* of the query in a functional style. The `cellCallback` parameter is a
|
|
2351
|
+
* ResultCellCallback function that will be called with the Id and value of
|
|
2352
|
+
* each ResultCell.
|
|
2189
2353
|
*
|
|
2190
2354
|
* @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
|
|
2355
|
+
* @param rowId The Id of a ResultRow in the query's ResultTable.
|
|
2356
|
+
* @param cellCallback The function that should be called for every ResultCell
|
|
2357
|
+
* of the query's ResultRow.
|
|
2194
2358
|
* @example
|
|
2195
|
-
* This example iterates over each
|
|
2359
|
+
* This example iterates over each ResultCell in a query's ResultRow.
|
|
2196
2360
|
*
|
|
2197
2361
|
* ```js
|
|
2198
2362
|
* const store = createStore().setTable('pets', {
|
|
@@ -2220,28 +2384,32 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2220
2384
|
* @category Iterator
|
|
2221
2385
|
* @since v2.0.0
|
|
2222
2386
|
*/
|
|
2223
|
-
forEachResultCell(
|
|
2387
|
+
forEachResultCell(
|
|
2388
|
+
queryId: Id,
|
|
2389
|
+
rowId: Id,
|
|
2390
|
+
cellCallback: ResultCellCallback,
|
|
2391
|
+
): void;
|
|
2224
2392
|
|
|
2225
2393
|
/**
|
|
2226
2394
|
* The addResultTableListener method registers a listener function with the
|
|
2227
|
-
* Queries object that will be called whenever data in a
|
|
2395
|
+
* Queries object that will be called whenever data in a ResultTable changes.
|
|
2228
2396
|
*
|
|
2229
2397
|
* 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.
|
|
2398
|
+
* with a reference to the Queries object, the Id of the ResultTable that
|
|
2399
|
+
* changed (which is also the query Id), and a GetCellResultChange function in
|
|
2400
|
+
* case you need to inspect any changes that occurred.
|
|
2233
2401
|
*
|
|
2234
|
-
* You can either listen to a single
|
|
2235
|
-
* the method's first parameter) or changes to any
|
|
2236
|
-
*
|
|
2402
|
+
* You can either listen to a single ResultTable (by specifying a query Id as
|
|
2403
|
+
* the method's first parameter) or changes to any ResultTable (by providing a
|
|
2404
|
+
* `null` wildcard).
|
|
2237
2405
|
*
|
|
2238
2406
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2239
2407
|
* @param listener The function that will be called whenever data in the
|
|
2240
|
-
* matching
|
|
2408
|
+
* matching ResultTable changes.
|
|
2241
2409
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2242
2410
|
* @example
|
|
2243
2411
|
* This example registers a listener that responds to any changes to a
|
|
2244
|
-
* specific
|
|
2412
|
+
* specific ResultTable.
|
|
2245
2413
|
*
|
|
2246
2414
|
* ```js
|
|
2247
2415
|
* const store = createStore().setTable('pets', {
|
|
@@ -2275,7 +2443,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2275
2443
|
* ```
|
|
2276
2444
|
* @example
|
|
2277
2445
|
* This example registers a listener that responds to any changes to any
|
|
2278
|
-
*
|
|
2446
|
+
* ResultTable.
|
|
2279
2447
|
*
|
|
2280
2448
|
* ```js
|
|
2281
2449
|
* const store = createStore().setTable('pets', {
|
|
@@ -2315,28 +2483,28 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2315
2483
|
|
|
2316
2484
|
/**
|
|
2317
2485
|
* The addResultRowIdsListener method registers a listener function with the
|
|
2318
|
-
* Queries object that will be called whenever the
|
|
2319
|
-
* change.
|
|
2486
|
+
* Queries object that will be called whenever the ResultRow Ids in a
|
|
2487
|
+
* ResultTable change.
|
|
2320
2488
|
*
|
|
2321
2489
|
* 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).
|
|
2490
|
+
* called with a reference to the Queries object and the Id of the ResultTable
|
|
2491
|
+
* that changed (which is also the query Id).
|
|
2324
2492
|
*
|
|
2325
|
-
* By default, such a listener is only called when a
|
|
2326
|
-
* removed from, the
|
|
2327
|
-
*
|
|
2493
|
+
* By default, such a listener is only called when a ResultRow is added to, or
|
|
2494
|
+
* removed from, the ResultTable. To listen to all changes in the ResultTable,
|
|
2495
|
+
* use the addResultTableListener method.
|
|
2328
2496
|
*
|
|
2329
|
-
* You can either listen to a single
|
|
2330
|
-
* the method's first parameter) or changes to any
|
|
2331
|
-
*
|
|
2497
|
+
* You can either listen to a single ResultTable (by specifying a query Id as
|
|
2498
|
+
* the method's first parameter) or changes to any ResultTable (by providing a
|
|
2499
|
+
* `null` wildcard).
|
|
2332
2500
|
*
|
|
2333
2501
|
* @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
|
|
2502
|
+
* @param listener The function that will be called whenever the ResultRow Ids
|
|
2503
|
+
* in the ResultTable change.
|
|
2336
2504
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2337
2505
|
* @example
|
|
2338
|
-
* This example registers a listener that responds to any change to the
|
|
2339
|
-
* Ids of a specific
|
|
2506
|
+
* This example registers a listener that responds to any change to the
|
|
2507
|
+
* ResultRow Ids of a specific ResultTable.
|
|
2340
2508
|
*
|
|
2341
2509
|
* ```js
|
|
2342
2510
|
* const store = createStore().setTable('pets', {
|
|
@@ -2369,8 +2537,8 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2369
2537
|
* store.delListener(listenerId);
|
|
2370
2538
|
* ```
|
|
2371
2539
|
* @example
|
|
2372
|
-
* This example registers a listener that responds to any change to the
|
|
2373
|
-
* Ids of any
|
|
2540
|
+
* This example registers a listener that responds to any change to the
|
|
2541
|
+
* ResultRow Ids of any ResultTable.
|
|
2374
2542
|
*
|
|
2375
2543
|
* ```js
|
|
2376
2544
|
* const store = createStore().setTable('pets', {
|
|
@@ -2414,44 +2582,44 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2414
2582
|
/**
|
|
2415
2583
|
* The addResultSortedRowIdsListener method registers a listener function with
|
|
2416
2584
|
* the Queries object that will be called whenever sorted (and optionally,
|
|
2417
|
-
* paginated)
|
|
2585
|
+
* paginated) ResultRow Ids in a ResultTable change.
|
|
2418
2586
|
*
|
|
2419
2587
|
* 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
|
|
2588
|
+
* called with a reference to the Queries object, the Id of the ResultTable
|
|
2589
|
+
* whose ResultRow Ids sorting changed (which is also the query Id), the
|
|
2590
|
+
* ResultCell Id being used to sort them, whether descending or not, and the
|
|
2591
|
+
* offset and limit of the number of Ids returned, for pagination purposes. It
|
|
2592
|
+
* also receives the sorted array of Ids itself, so that you can use them in
|
|
2593
|
+
* the listener without the additional cost of an explicit call to
|
|
2426
2594
|
* getResultSortedRowIds
|
|
2427
2595
|
*
|
|
2428
|
-
* Such a listener is called when a
|
|
2429
|
-
* value in the specified
|
|
2430
|
-
* enough to change the sorting of the
|
|
2596
|
+
* Such a listener is called when a ResultRow is added or removed, but also
|
|
2597
|
+
* when a value in the specified ResultCell (somewhere in the ResultTable) has
|
|
2598
|
+
* changed enough to change the sorting of the ResultRow Ids.
|
|
2431
2599
|
*
|
|
2432
2600
|
* Unlike most other listeners, you cannot provide wildcards (due to the cost
|
|
2433
2601
|
* of detecting changes to the sorting). You can only listen to a single
|
|
2434
|
-
* specified
|
|
2602
|
+
* specified ResultTable, sorted by a single specified ResultCell.
|
|
2435
2603
|
*
|
|
2436
2604
|
* The sorting of the rows is alphanumeric, and you can indicate whether it
|
|
2437
2605
|
* should be in descending order. The `offset` and `limit` parameters are used
|
|
2438
2606
|
* to paginate results, but default to `0` and `undefined` to return all
|
|
2439
|
-
* available
|
|
2607
|
+
* available ResultRow Ids if not specified.
|
|
2440
2608
|
*
|
|
2441
2609
|
* @param queryId The Id of the query to listen to.
|
|
2442
|
-
* @param cellId The Id of the
|
|
2443
|
-
* `undefined` to by sort the
|
|
2610
|
+
* @param cellId The Id of the ResultCell whose values are used for the
|
|
2611
|
+
* sorting, or `undefined` to by sort the ResultRow Id itself.
|
|
2444
2612
|
* @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
|
|
2613
|
+
* @param offset The number of ResultRow Ids to skip for pagination purposes,
|
|
2614
|
+
* if any.
|
|
2615
|
+
* @param limit The maximum number of ResultRow Ids to return, or `undefined`
|
|
2616
|
+
* for all.
|
|
2617
|
+
* @param listener The function that will be called whenever the sorted
|
|
2618
|
+
* ResultRow Ids in the ResultTable change.
|
|
2451
2619
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2452
2620
|
* @example
|
|
2453
2621
|
* This example registers a listener that responds to any change to the sorted
|
|
2454
|
-
*
|
|
2622
|
+
* ResultRow Ids of a specific ResultTable.
|
|
2455
2623
|
*
|
|
2456
2624
|
* ```js
|
|
2457
2625
|
* const store = createStore().setTable('pets', {
|
|
@@ -2476,22 +2644,22 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2476
2644
|
* 0,
|
|
2477
2645
|
* undefined,
|
|
2478
2646
|
* (queries, tableId, cellId, descending, offset, limit, sortedRowIds) => {
|
|
2479
|
-
* console.log(`Sorted
|
|
2647
|
+
* console.log(`Sorted row Ids for dogColors result table changed`);
|
|
2480
2648
|
* console.log(sortedRowIds);
|
|
2481
2649
|
* // ^ cheaper than calling getResultSortedRowIds again
|
|
2482
2650
|
* },
|
|
2483
2651
|
* );
|
|
2484
2652
|
*
|
|
2485
2653
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'});
|
|
2486
|
-
* // -> 'Sorted
|
|
2654
|
+
* // -> 'Sorted row Ids for dogColors result table changed'
|
|
2487
2655
|
* // -> ['cujo', 'fido', 'rex']
|
|
2488
2656
|
*
|
|
2489
2657
|
* store.delListener(listenerId);
|
|
2490
2658
|
* ```
|
|
2491
2659
|
* @example
|
|
2492
2660
|
* This example registers a listener that responds to any change to the sorted
|
|
2493
|
-
*
|
|
2494
|
-
* since the `cellId` parameter is explicitly undefined.
|
|
2661
|
+
* ResultRow Ids of a specific ResultTable. The ResultRow Ids are sorted by
|
|
2662
|
+
* their own value, since the `cellId` parameter is explicitly undefined.
|
|
2495
2663
|
*
|
|
2496
2664
|
* ```js
|
|
2497
2665
|
* const store = createStore().setTable('pets', {
|
|
@@ -2518,14 +2686,14 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2518
2686
|
* 0,
|
|
2519
2687
|
* undefined,
|
|
2520
2688
|
* (queries, tableId, cellId, descending, offset, limit, sortedRowIds) => {
|
|
2521
|
-
* console.log(`Sorted
|
|
2689
|
+
* console.log(`Sorted row Ids for dogColors result table changed`);
|
|
2522
2690
|
* console.log(sortedRowIds);
|
|
2523
2691
|
* // ^ cheaper than calling getSortedRowIds again
|
|
2524
2692
|
* },
|
|
2525
2693
|
* );
|
|
2526
2694
|
*
|
|
2527
2695
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'});
|
|
2528
|
-
* // -> 'Sorted
|
|
2696
|
+
* // -> 'Sorted row Ids for dogColors result table changed'
|
|
2529
2697
|
* // -> ['cujo', 'fido', 'rex']
|
|
2530
2698
|
*
|
|
2531
2699
|
* store.delListener(listenerId);
|
|
@@ -2544,31 +2712,30 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2544
2712
|
|
|
2545
2713
|
/**
|
|
2546
2714
|
* The addResultRowListener method registers a listener function with the
|
|
2547
|
-
* Queries object that will be called whenever data in a
|
|
2715
|
+
* Queries object that will be called whenever data in a ResultRow changes.
|
|
2548
2716
|
*
|
|
2549
2717
|
* 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.
|
|
2718
|
+
* with a reference to the Queries object, the Id of the ResultTable that
|
|
2719
|
+
* changed (which is also the query Id), and a GetCellResultChange function in
|
|
2720
|
+
* case you need to inspect any changes that occurred.
|
|
2553
2721
|
*
|
|
2554
|
-
* You can either listen to a single
|
|
2555
|
-
*
|
|
2556
|
-
* (by providing `null` wildcards).
|
|
2722
|
+
* You can either listen to a single ResultRow (by specifying a query Id and
|
|
2723
|
+
* ResultRow Id as the method's first two parameters) or changes to any
|
|
2724
|
+
* ResultRow (by providing `null` wildcards).
|
|
2557
2725
|
*
|
|
2558
2726
|
* 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
|
-
*
|
|
2727
|
+
* wildcarded with `null`. You can listen to a specific ResultRow in a
|
|
2728
|
+
* specific query, any ResultRow in a specific query, a specific ResultRow in
|
|
2729
|
+
* any query, or any ResultRow in any query.
|
|
2562
2730
|
*
|
|
2563
2731
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2564
|
-
* @param rowId The Id of the
|
|
2565
|
-
* wildcard.
|
|
2732
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
2566
2733
|
* @param listener The function that will be called whenever data in the
|
|
2567
|
-
* matching
|
|
2734
|
+
* matching ResultRow changes.
|
|
2568
2735
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2569
2736
|
* @example
|
|
2570
2737
|
* This example registers a listener that responds to any changes to a
|
|
2571
|
-
* specific
|
|
2738
|
+
* specific ResultRow.
|
|
2572
2739
|
*
|
|
2573
2740
|
* ```js
|
|
2574
2741
|
* const store = createStore().setTable('pets', {
|
|
@@ -2603,7 +2770,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2603
2770
|
* ```
|
|
2604
2771
|
* @example
|
|
2605
2772
|
* This example registers a listener that responds to any changes to any
|
|
2606
|
-
*
|
|
2773
|
+
* ResultRow.
|
|
2607
2774
|
*
|
|
2608
2775
|
* ```js
|
|
2609
2776
|
* const store = createStore().setTable('pets', {
|
|
@@ -2648,35 +2815,34 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2648
2815
|
|
|
2649
2816
|
/**
|
|
2650
2817
|
* The addResultCellIdsListener method registers a listener function with the
|
|
2651
|
-
* Queries object that will be called whenever the
|
|
2652
|
-
* change.
|
|
2818
|
+
* Queries object that will be called whenever the ResultCell Ids in a
|
|
2819
|
+
* ResultRow change.
|
|
2653
2820
|
*
|
|
2654
2821
|
* 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
|
|
2822
|
+
* called with a reference to the Queries object, the Id of the ResultTable
|
|
2823
|
+
* (which is also the query Id), and the Id of the ResultRow that changed.
|
|
2657
2824
|
*
|
|
2658
|
-
* Such a listener is only called when a
|
|
2659
|
-
* the
|
|
2825
|
+
* Such a listener is only called when a ResultCell is added to, or removed
|
|
2826
|
+
* from, the ResultRow. To listen to all changes in the ResultRow, use the
|
|
2660
2827
|
* addResultRowListener method.
|
|
2661
2828
|
*
|
|
2662
|
-
* You can either listen to a single
|
|
2663
|
-
*
|
|
2664
|
-
* providing `null` wildcards).
|
|
2829
|
+
* You can either listen to a single ResultRow (by specifying the query Id and
|
|
2830
|
+
* ResultRow Id as the method's first two parameters) or changes to any
|
|
2831
|
+
* ResultRow (by providing `null` wildcards).
|
|
2665
2832
|
*
|
|
2666
2833
|
* 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
|
-
*
|
|
2834
|
+
* wildcarded with `null`. You can listen to a specific ResultRow in a
|
|
2835
|
+
* specific query, any ResultRow in a specific query, a specific ResultRow in
|
|
2836
|
+
* any query, or any ResultRow in any query.
|
|
2670
2837
|
*
|
|
2671
2838
|
* @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.
|
|
2839
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
2840
|
+
* @param listener The function that will be called whenever the ResultCell
|
|
2841
|
+
* Ids in the ResultRow change.
|
|
2676
2842
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2677
2843
|
* @example
|
|
2678
|
-
* This example registers a listener that responds to any change to the
|
|
2679
|
-
* Ids of a specific
|
|
2844
|
+
* This example registers a listener that responds to any change to the
|
|
2845
|
+
* ResultCell Ids of a specific ResultRow.
|
|
2680
2846
|
*
|
|
2681
2847
|
* ```js
|
|
2682
2848
|
* const store = createStore().setTable('pets', {
|
|
@@ -2711,8 +2877,8 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2711
2877
|
* store.delListener(listenerId);
|
|
2712
2878
|
* ```
|
|
2713
2879
|
* @example
|
|
2714
|
-
* This example registers a listener that responds to any change to the
|
|
2715
|
-
* Ids of any
|
|
2880
|
+
* This example registers a listener that responds to any change to the
|
|
2881
|
+
* ResultCell Ids of any ResultRow.
|
|
2716
2882
|
*
|
|
2717
2883
|
* ```js
|
|
2718
2884
|
* const store = createStore().setTable('pets', {
|
|
@@ -2761,35 +2927,34 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2761
2927
|
|
|
2762
2928
|
/**
|
|
2763
2929
|
* The addResultCellListener method registers a listener function with the
|
|
2764
|
-
* Queries object that will be called whenever data in a
|
|
2930
|
+
* Queries object that will be called whenever data in a ResultCell changes.
|
|
2765
2931
|
*
|
|
2766
2932
|
* 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.
|
|
2933
|
+
* with a reference to the Queries object, the Id of the ResultTable that
|
|
2934
|
+
* changed (which is also the query Id), the Id of the ResultRow that changed,
|
|
2935
|
+
* the Id of the ResultCell that changed, the new ResultCell value, the old
|
|
2936
|
+
* ResultCell value, and a GetCellResultChange function in case you need to
|
|
2937
|
+
* inspect any changes that occurred.
|
|
2772
2938
|
*
|
|
2773
|
-
* You can either listen to a single
|
|
2774
|
-
* Id, and
|
|
2775
|
-
*
|
|
2939
|
+
* You can either listen to a single ResultRow (by specifying a query Id,
|
|
2940
|
+
* ResultRow Id, and ResultCell Id as the method's first three parameters) or
|
|
2941
|
+
* changes to any ResultCell (by providing `null` wildcards).
|
|
2776
2942
|
*
|
|
2777
2943
|
* 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.
|
|
2944
|
+
* be wildcarded with `null`. You can listen to a specific ResultCell in a
|
|
2945
|
+
* specific ResultRow in a specific query, any ResultCell in any ResultRow in
|
|
2946
|
+
* any query, for example - or every other combination of wildcards.
|
|
2781
2947
|
*
|
|
2782
2948
|
* @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
|
|
2949
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
2950
|
+
* @param cellId The Id of the ResultCell to listen to, or `null` as a
|
|
2786
2951
|
* wildcard.
|
|
2787
2952
|
* @param listener The function that will be called whenever data in the
|
|
2788
|
-
* matching
|
|
2953
|
+
* matching ResultCell changes.
|
|
2789
2954
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2790
2955
|
* @example
|
|
2791
2956
|
* This example registers a listener that responds to any changes to a
|
|
2792
|
-
* specific
|
|
2957
|
+
* specific ResultCell.
|
|
2793
2958
|
*
|
|
2794
2959
|
* ```js
|
|
2795
2960
|
* const store = createStore().setTable('pets', {
|
|
@@ -2829,7 +2994,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2829
2994
|
* ```
|
|
2830
2995
|
* @example
|
|
2831
2996
|
* This example registers a listener that responds to any changes to any
|
|
2832
|
-
*
|
|
2997
|
+
* ResultCell.
|
|
2833
2998
|
*
|
|
2834
2999
|
* ```js
|
|
2835
3000
|
* const store = createStore().setTable('pets', {
|
|
@@ -2921,7 +3086,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2921
3086
|
* @category Listener
|
|
2922
3087
|
* @since v2.0.0
|
|
2923
3088
|
*/
|
|
2924
|
-
delListener(listenerId: Id): Queries
|
|
3089
|
+
delListener(listenerId: Id): Queries;
|
|
2925
3090
|
|
|
2926
3091
|
/**
|
|
2927
3092
|
* The destroy method should be called when this Queries object is no longer
|
|
@@ -3023,6 +3188,4 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
3023
3188
|
* @category Creation
|
|
3024
3189
|
* @since v2.0.0
|
|
3025
3190
|
*/
|
|
3026
|
-
export function createQueries
|
|
3027
|
-
store: Store<Schemas>,
|
|
3028
|
-
): Queries<Schemas>;
|
|
3191
|
+
export function createQueries(store: Store): Queries;
|