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
|
@@ -14,20 +14,79 @@
|
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
Cell,
|
|
17
|
-
CellCallback,
|
|
18
17
|
CellOrUndefined,
|
|
19
18
|
GetCell,
|
|
20
|
-
|
|
21
|
-
NoSchemas,
|
|
19
|
+
NoTablesSchema,
|
|
22
20
|
OptionalSchemas,
|
|
23
|
-
|
|
24
|
-
RowCallback,
|
|
21
|
+
OptionalTablesSchema,
|
|
25
22
|
Store,
|
|
26
|
-
Table,
|
|
27
|
-
TableCallback,
|
|
28
23
|
} from './store.d';
|
|
24
|
+
import {CellIdFromSchema, TableIdFromSchema} from './internal/store';
|
|
25
|
+
import {GetResultCell, JoinedCellIdOrId} from './internal/queries';
|
|
29
26
|
import {Id, IdOrNull, Ids} from './common.d';
|
|
30
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The ResultTable type is the data structure representing the results of a
|
|
30
|
+
* query.
|
|
31
|
+
*
|
|
32
|
+
* A ResultTable is typically accessed with the getResultTable method or
|
|
33
|
+
* addResultTableListener method. It is similar to the Table type in the store
|
|
34
|
+
* module, but without schema-specific typing, and is a regular JavaScript
|
|
35
|
+
* object containing individual ResultRow objects, keyed by their Id.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```js
|
|
39
|
+
* const resultTable: ResultTable = {
|
|
40
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
41
|
+
* felix: {species: 'cat'},
|
|
42
|
+
* };
|
|
43
|
+
* ```
|
|
44
|
+
* @category Result
|
|
45
|
+
*/
|
|
46
|
+
export type ResultTable = {[rowId: Id]: ResultRow};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The ResultRow type is the data structure representing a single row in the
|
|
50
|
+
* results of a query.
|
|
51
|
+
*
|
|
52
|
+
* A ResultRow is typically accessed with the getResultRow method or
|
|
53
|
+
* addResultRowListener method. It is similar to the Row type in the store
|
|
54
|
+
* module, but without schema-specific typing, and is a regular JavaScript
|
|
55
|
+
* object containing individual ResultCell objects, keyed by their Id.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```js
|
|
59
|
+
* const resultRow: ResultRow = {species: 'dog', color: 'brown'};
|
|
60
|
+
* ```
|
|
61
|
+
* @category Result
|
|
62
|
+
*/
|
|
63
|
+
export type ResultRow = {[cellId: Id]: ResultCell};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The ResultCell type is the data structure representing a single cell in the
|
|
67
|
+
* results of a query.
|
|
68
|
+
*
|
|
69
|
+
* A ResultCell is typically accessed with the getResultCell method or
|
|
70
|
+
* addResultCellListener method. It is similar to the Cell type in the store
|
|
71
|
+
* module, but without schema-specific typing, and is a JavaScript string,
|
|
72
|
+
* number, or boolean.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```js
|
|
76
|
+
* const resultCell: ResultCell = 'dog';
|
|
77
|
+
* ```
|
|
78
|
+
* @category Result
|
|
79
|
+
*/
|
|
80
|
+
export type ResultCell = string | number | boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The ResultCellOrUndefined type is the data structure representing a single
|
|
84
|
+
* cell in the results of a query, or the value `undefined`.
|
|
85
|
+
*
|
|
86
|
+
* @category Result
|
|
87
|
+
*/
|
|
88
|
+
export type ResultCellOrUndefined = ResultCell | undefined;
|
|
89
|
+
|
|
31
90
|
/**
|
|
32
91
|
* The Aggregate type describes a custom function that takes an array of Cell
|
|
33
92
|
* values and returns an aggregate of them.
|
|
@@ -42,7 +101,7 @@ import {Id, IdOrNull, Ids} from './common.d';
|
|
|
42
101
|
* @category Aggregators
|
|
43
102
|
* @since v2.0.0
|
|
44
103
|
*/
|
|
45
|
-
export type Aggregate = (cells:
|
|
104
|
+
export type Aggregate = (cells: ResultCell[], length: number) => ResultCell;
|
|
46
105
|
|
|
47
106
|
/**
|
|
48
107
|
* The AggregateAdd type describes a function that can be used to optimize a
|
|
@@ -69,10 +128,10 @@ export type Aggregate = (cells: Cell[], length: number) => Cell;
|
|
|
69
128
|
* @since v2.0.0
|
|
70
129
|
*/
|
|
71
130
|
export type AggregateAdd = (
|
|
72
|
-
current:
|
|
73
|
-
add:
|
|
131
|
+
current: ResultCell,
|
|
132
|
+
add: ResultCell,
|
|
74
133
|
length: number,
|
|
75
|
-
) =>
|
|
134
|
+
) => ResultCellOrUndefined;
|
|
76
135
|
|
|
77
136
|
/**
|
|
78
137
|
* The AggregateRemove type describes a function that can be used to optimize a
|
|
@@ -102,10 +161,10 @@ export type AggregateAdd = (
|
|
|
102
161
|
* @since v2.0.0
|
|
103
162
|
*/
|
|
104
163
|
export type AggregateRemove = (
|
|
105
|
-
current:
|
|
106
|
-
remove:
|
|
164
|
+
current: ResultCell,
|
|
165
|
+
remove: ResultCell,
|
|
107
166
|
length: number,
|
|
108
|
-
) =>
|
|
167
|
+
) => ResultCellOrUndefined;
|
|
109
168
|
|
|
110
169
|
/**
|
|
111
170
|
* The AggregateReplace type describes a function that can be used to optimize a
|
|
@@ -134,11 +193,11 @@ export type AggregateRemove = (
|
|
|
134
193
|
* @since v2.0.0
|
|
135
194
|
*/
|
|
136
195
|
export type AggregateReplace = (
|
|
137
|
-
current:
|
|
138
|
-
add:
|
|
139
|
-
remove:
|
|
196
|
+
current: ResultCell,
|
|
197
|
+
add: ResultCell,
|
|
198
|
+
remove: ResultCell,
|
|
140
199
|
length: number,
|
|
141
|
-
) =>
|
|
200
|
+
) => ResultCellOrUndefined;
|
|
142
201
|
|
|
143
202
|
/**
|
|
144
203
|
* The QueryCallback type describes a function that takes a query's Id.
|
|
@@ -153,76 +212,133 @@ export type AggregateReplace = (
|
|
|
153
212
|
*/
|
|
154
213
|
export type QueryCallback = (queryId: Id) => void;
|
|
155
214
|
|
|
215
|
+
/**
|
|
216
|
+
* The ResultTableCallback type describes a function that takes a ResultTable's
|
|
217
|
+
* Id and a callback to loop over each ResultRow within it.
|
|
218
|
+
*
|
|
219
|
+
* A ResultTableCallback is provided when using the forEachResultTable method,
|
|
220
|
+
* so that you can do something based on every ResultTable in the Queries
|
|
221
|
+
* object. See that method for specific examples.
|
|
222
|
+
*
|
|
223
|
+
* @param tableId The Id of the ResultTable that the callback can operate on.
|
|
224
|
+
* @param forEachRow A function that will let you iterate over the ResultRow
|
|
225
|
+
* objects in this ResultTable.
|
|
226
|
+
* @category Callback
|
|
227
|
+
*/
|
|
228
|
+
export type ResultTableCallback = (
|
|
229
|
+
tableId: Id,
|
|
230
|
+
forEachRow: (rowCallback: ResultRowCallback) => void,
|
|
231
|
+
) => void;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* The ResultRowCallback type describes a function that takes a ResultRow's Id
|
|
235
|
+
* and a callback to loop over each ResultCell within it.
|
|
236
|
+
*
|
|
237
|
+
* A ResultRowCallback is provided when using the forEachResultRow method, so
|
|
238
|
+
* that you can do something based on every ResultRow in a ResultTable. See that
|
|
239
|
+
* method for specific examples.
|
|
240
|
+
*
|
|
241
|
+
* @param rowId The Id of the ResultRow that the callback can operate on.
|
|
242
|
+
* @param forEachRow A function that will let you iterate over the ResultCell
|
|
243
|
+
* values in this ResultRow.
|
|
244
|
+
* @category Callback
|
|
245
|
+
*/
|
|
246
|
+
export type ResultRowCallback = (
|
|
247
|
+
rowId: Id,
|
|
248
|
+
forEachCell: (cellCallback: ResultCellCallback) => void,
|
|
249
|
+
) => void;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The ResultCellCallback type describes a function that takes a ResultCell's Id
|
|
253
|
+
* and its value.
|
|
254
|
+
*
|
|
255
|
+
* A ResultCellCallback is provided when using the forEachResultCell method, so
|
|
256
|
+
* that you can do something based on every ResultCell in a ResultRow. See that
|
|
257
|
+
* method for specific examples.
|
|
258
|
+
*
|
|
259
|
+
* @param cellId The Id of the ResultCell that the callback can operate on.
|
|
260
|
+
* @param cell The value of the ResultCell.
|
|
261
|
+
* @category Callback
|
|
262
|
+
*/
|
|
263
|
+
export type ResultCellCallback = (cellId: Id, cell: ResultCell) => void;
|
|
264
|
+
|
|
156
265
|
/**
|
|
157
266
|
* The ResultTableListener type describes a function that is used to listen to
|
|
158
|
-
* changes to a query's
|
|
267
|
+
* changes to a query's ResultTable.
|
|
159
268
|
*
|
|
160
269
|
* A ResultTableListener is provided when using the addResultTableListener
|
|
161
270
|
* method. See that method for specific examples.
|
|
162
271
|
*
|
|
163
272
|
* When called, a ResultTableListener is given a reference to the Queries
|
|
164
|
-
* object, the Id of the
|
|
165
|
-
* and a
|
|
166
|
-
* after the change.
|
|
273
|
+
* object, the Id of the ResultTable that changed (which is the same as the
|
|
274
|
+
* query Id), and a GetCellResultChange function that can be used to query
|
|
275
|
+
* ResultCell values before and after the change.
|
|
167
276
|
*
|
|
168
277
|
* @param queries A reference to the Queries object that changed.
|
|
169
|
-
* @param tableId The Id of the
|
|
170
|
-
*
|
|
171
|
-
*
|
|
278
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
279
|
+
* query Id.
|
|
280
|
+
* @param getCellChange A function that returns information about any
|
|
281
|
+
* ResultCell's changes.
|
|
172
282
|
* @category Listener
|
|
173
283
|
* @since v2.0.0
|
|
174
284
|
*/
|
|
175
|
-
export type ResultTableListener = (
|
|
176
|
-
queries: Queries
|
|
285
|
+
export type ResultTableListener<Schemas extends OptionalSchemas> = (
|
|
286
|
+
queries: Queries<Schemas>,
|
|
177
287
|
tableId: Id,
|
|
178
|
-
getCellChange:
|
|
288
|
+
getCellChange: GetCellResultChange,
|
|
179
289
|
) => void;
|
|
180
290
|
|
|
181
291
|
/**
|
|
182
292
|
* The ResultRowIdsListener type describes a function that is used to listen to
|
|
183
|
-
* changes to the
|
|
293
|
+
* changes to the ResultRow Ids in a query's ResultTable.
|
|
184
294
|
*
|
|
185
295
|
* A ResultRowIdsListener is provided when using the addResultRowIdsListener
|
|
186
296
|
* method. See that method for specific examples.
|
|
187
297
|
*
|
|
188
298
|
* When called, a ResultRowIdsListener is given a reference to the Queries
|
|
189
|
-
* object, and the Id of the
|
|
190
|
-
* the query Id).
|
|
299
|
+
* object, and the Id of the ResultTable whose ResultRow Ids changed (which is
|
|
300
|
+
* the same as the query Id).
|
|
191
301
|
*
|
|
192
302
|
* @param queries A reference to the Queries object that changed.
|
|
193
|
-
* @param tableId The Id of the
|
|
303
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
304
|
+
* query Id.
|
|
194
305
|
* @category Listener
|
|
195
306
|
* @since v2.0.0
|
|
196
307
|
*/
|
|
197
|
-
export type ResultRowIdsListener = (
|
|
308
|
+
export type ResultRowIdsListener<Schemas extends OptionalSchemas> = (
|
|
309
|
+
queries: Queries<Schemas>,
|
|
310
|
+
tableId: Id,
|
|
311
|
+
) => void;
|
|
198
312
|
|
|
199
313
|
/**
|
|
200
314
|
* The ResultSortedRowIdsListener type describes a function that is used to
|
|
201
|
-
* listen to changes to the sorted
|
|
315
|
+
* listen to changes to the sorted ResultRow Ids in a query's ResultTable.
|
|
202
316
|
*
|
|
203
317
|
* A ResultSortedRowIdsListener is provided when using the
|
|
204
318
|
* addResultSortedRowIdsListener method. See that method for specific examples.
|
|
205
319
|
*
|
|
206
320
|
* 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.
|
|
321
|
+
* object, the Id of the ResultTable whose ResultRow Ids changed (which is the
|
|
322
|
+
* same as the query Id), the ResultCell Id being used to sort them, whether
|
|
323
|
+
* descending or not, and the offset and limit of the number of Ids returned,
|
|
324
|
+
* for pagination purposes. It also receives the sorted array of Ids itself, so
|
|
325
|
+
* that you can use them in the listener without the additional cost of an
|
|
326
|
+
* explicit call to getResultSortedRowIds.
|
|
213
327
|
*
|
|
214
328
|
* @param queries A reference to the Queries object that changed.
|
|
215
|
-
* @param tableId The Id of the
|
|
216
|
-
*
|
|
329
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
330
|
+
* query Id.
|
|
331
|
+
* @param cellId The Id of the ResultCell whose values were used for the
|
|
332
|
+
* sorting.
|
|
217
333
|
* @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
|
|
334
|
+
* @param offset The number of ResultRow Ids skipped.
|
|
335
|
+
* @param limit The maximum number of ResultRow Ids returned.
|
|
336
|
+
* @param sortedRowIds The sorted ResultRow Ids themselves.
|
|
221
337
|
* @category Listener
|
|
222
338
|
* @since v2.0.0
|
|
223
339
|
*/
|
|
224
|
-
export type ResultSortedRowIdsListener = (
|
|
225
|
-
queries: Queries
|
|
340
|
+
export type ResultSortedRowIdsListener<Schemas extends OptionalSchemas> = (
|
|
341
|
+
queries: Queries<Schemas>,
|
|
226
342
|
tableId: Id,
|
|
227
343
|
cellId: Id | undefined,
|
|
228
344
|
descending: boolean,
|
|
@@ -233,88 +349,131 @@ export type ResultSortedRowIdsListener = (
|
|
|
233
349
|
|
|
234
350
|
/**
|
|
235
351
|
* The ResultRowListener type describes a function that is used to listen to
|
|
236
|
-
* changes to a
|
|
352
|
+
* changes to a ResultRow in a query's ResultTable.
|
|
237
353
|
*
|
|
238
354
|
* A ResultRowListener is provided when using the addResultRowListener method.
|
|
239
355
|
* See that method for specific examples.
|
|
240
356
|
*
|
|
241
357
|
* When called, a ResultRowListener is given a reference to the Queries object,
|
|
242
|
-
* the Id of the
|
|
243
|
-
* of the
|
|
244
|
-
* query
|
|
358
|
+
* the Id of the ResultTable that changed (which is the same as the query Id),
|
|
359
|
+
* the Id of the ResultRow that changed, and a GetCellResultChange function that
|
|
360
|
+
* can be used to query ResultCell values before and after the change.
|
|
245
361
|
*
|
|
246
362
|
* @param queries A reference to the Queries object that changed.
|
|
247
|
-
* @param tableId The Id of the
|
|
248
|
-
*
|
|
249
|
-
* @param
|
|
250
|
-
*
|
|
363
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
364
|
+
* query Id.
|
|
365
|
+
* @param rowId The Id of the ResultRow that changed.
|
|
366
|
+
* @param getCellChange A function that returns information about any
|
|
367
|
+
* ResultCell's changes.
|
|
251
368
|
* @category Listener
|
|
252
369
|
* @since v2.0.0
|
|
253
370
|
*/
|
|
254
|
-
export type ResultRowListener = (
|
|
255
|
-
queries: Queries
|
|
371
|
+
export type ResultRowListener<Schemas extends OptionalSchemas> = (
|
|
372
|
+
queries: Queries<Schemas>,
|
|
256
373
|
tableId: Id,
|
|
257
374
|
rowId: Id,
|
|
258
|
-
getCellChange:
|
|
375
|
+
getCellChange: GetCellResultChange,
|
|
259
376
|
) => void;
|
|
260
377
|
|
|
261
378
|
/**
|
|
262
379
|
* The ResultCellIdsListener type describes a function that is used to listen to
|
|
263
|
-
* changes to the
|
|
380
|
+
* changes to the ResultCell Ids in a ResultRow in a query's ResultTable.
|
|
264
381
|
*
|
|
265
382
|
* A ResultCellIdsListener is provided when using the addResultCellIdsListener
|
|
266
383
|
* method. See that method for specific examples.
|
|
267
384
|
*
|
|
268
385
|
* When called, a ResultCellIdsListener is given a reference to the Queries
|
|
269
|
-
* object, the Id of the
|
|
270
|
-
* and the Id of the
|
|
386
|
+
* object, the Id of the ResultTable that changed (which is the same as the
|
|
387
|
+
* query Id), and the Id of the ResultRow whose ResultCell Ids changed.
|
|
271
388
|
*
|
|
272
389
|
* @param queries A reference to the Queries object that changed.
|
|
273
|
-
* @param tableId The Id of the
|
|
274
|
-
*
|
|
390
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
391
|
+
* query Id.
|
|
392
|
+
* @param rowId The Id of the ResultRow that changed.
|
|
275
393
|
* @category Listener
|
|
276
394
|
* @since v2.0.0
|
|
277
395
|
*/
|
|
278
|
-
export type ResultCellIdsListener = (
|
|
279
|
-
queries: Queries
|
|
396
|
+
export type ResultCellIdsListener<Schemas extends OptionalSchemas> = (
|
|
397
|
+
queries: Queries<Schemas>,
|
|
280
398
|
tableId: Id,
|
|
281
399
|
rowId: Id,
|
|
282
400
|
) => void;
|
|
283
401
|
|
|
284
402
|
/**
|
|
285
403
|
* The ResultCellListener type describes a function that is used to listen to
|
|
286
|
-
* changes to a
|
|
404
|
+
* changes to a ResultCell in a query's ResultTable.
|
|
287
405
|
*
|
|
288
406
|
* A ResultCellListener is provided when using the addResultCellListener method.
|
|
289
407
|
* See that method for specific examples.
|
|
290
408
|
*
|
|
291
409
|
* 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
|
|
410
|
+
* the Id of the ResultTable that changed (which is the same as the query Id),
|
|
411
|
+
* the Id of the ResultRow that changed, and the Id of ResultCell that changed.
|
|
412
|
+
* It is also given the new value of the ResultCell, the old value of the
|
|
413
|
+
* ResultCell, and a GetCellResultChange function that can be used to query
|
|
414
|
+
* ResultCell values before and after the change.
|
|
296
415
|
*
|
|
297
416
|
* @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
|
-
*
|
|
417
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
418
|
+
* query Id.
|
|
419
|
+
* @param rowId The Id of the ResultRow that changed.
|
|
420
|
+
* @param cellId The Id of the ResultCell that changed.
|
|
421
|
+
* @param newCell The new value of the ResultCell that changed.
|
|
422
|
+
* @param oldCell The old value of the ResultCell that changed.
|
|
423
|
+
* @param getCellChange A function that returns information about any
|
|
424
|
+
* ResultCell's changes.
|
|
305
425
|
* @category Listener
|
|
306
426
|
* @since v2.0.0
|
|
307
427
|
*/
|
|
308
|
-
export type ResultCellListener = (
|
|
309
|
-
queries: Queries
|
|
428
|
+
export type ResultCellListener<Schemas extends OptionalSchemas> = (
|
|
429
|
+
queries: Queries<Schemas>,
|
|
310
430
|
tableId: Id,
|
|
311
431
|
rowId: Id,
|
|
312
432
|
cellId: Id,
|
|
313
|
-
newCell:
|
|
314
|
-
oldCell:
|
|
315
|
-
getCellChange:
|
|
433
|
+
newCell: ResultCell,
|
|
434
|
+
oldCell: ResultCell,
|
|
435
|
+
getCellChange: GetCellResultChange,
|
|
316
436
|
) => void;
|
|
317
437
|
|
|
438
|
+
/**
|
|
439
|
+
* The GetCellResultChange type describes a function that returns information
|
|
440
|
+
* about any ResultCell's changes during a transaction.
|
|
441
|
+
*
|
|
442
|
+
* A GetCellResultChange function is provided to every listener when called due
|
|
443
|
+
* the Store changing. The listener can then fetch the previous value of a
|
|
444
|
+
* ResultCell before the current transaction, the new value after it, and a
|
|
445
|
+
* convenience flag that indicates that the value has changed.
|
|
446
|
+
*
|
|
447
|
+
* @param tableId The Id of the ResultTable to inspect.
|
|
448
|
+
* @param rowId The Id of the ResultRow to inspect.
|
|
449
|
+
* @param cellId The Id of the ResultCell to inspect.
|
|
450
|
+
* @returns A ResultCellChange array containing information about the
|
|
451
|
+
* ResultCell's changes.
|
|
452
|
+
* @category Listener
|
|
453
|
+
*/
|
|
454
|
+
export type GetCellResultChange = (
|
|
455
|
+
tableId: Id,
|
|
456
|
+
rowId: Id,
|
|
457
|
+
cellId: Id,
|
|
458
|
+
) => ResultCellChange;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* The ResultCellChange type describes a ResultCell's changes during a
|
|
462
|
+
* transaction.
|
|
463
|
+
*
|
|
464
|
+
* This is returned by the GetResultCellChange function that is provided to
|
|
465
|
+
* every listener when called. This array contains the previous value of a
|
|
466
|
+
* ResultCell before the current transaction, the new value after it, and a
|
|
467
|
+
* convenience flag that indicates that the value has changed.
|
|
468
|
+
*
|
|
469
|
+
* @category Listener
|
|
470
|
+
*/
|
|
471
|
+
export type ResultCellChange = [
|
|
472
|
+
changed: boolean,
|
|
473
|
+
oldCell: ResultCellOrUndefined,
|
|
474
|
+
newCell: ResultCellOrUndefined,
|
|
475
|
+
];
|
|
476
|
+
|
|
318
477
|
/**
|
|
319
478
|
* The QueriesListenerStats type describes the number of listeners registered
|
|
320
479
|
* with the Queries object, and can be used for debugging purposes.
|
|
@@ -359,20 +518,25 @@ export type QueriesListenerStats = {
|
|
|
359
518
|
* @category Callback
|
|
360
519
|
* @since v2.0.0
|
|
361
520
|
*/
|
|
362
|
-
export type GetTableCell
|
|
521
|
+
export type GetTableCell<
|
|
522
|
+
Schema extends OptionalTablesSchema,
|
|
523
|
+
RootTableId extends TableIdFromSchema<Schema>,
|
|
524
|
+
> = {
|
|
363
525
|
/**
|
|
364
|
-
* When called with one parameter, this function will return the value of
|
|
365
|
-
* specified Cell from the query's
|
|
366
|
-
* filtered.
|
|
526
|
+
* When called with one parameter, this function will return the value of
|
|
527
|
+
* the specified Cell from the query's root Table for the Row being selected
|
|
528
|
+
* or filtered.
|
|
367
529
|
*
|
|
368
530
|
* @param cellId The Id of the Cell to fetch the value for.
|
|
369
531
|
* @returns A Cell value or `undefined`.
|
|
370
532
|
*/
|
|
371
|
-
|
|
533
|
+
<RootCellId extends CellIdFromSchema<Schema, RootTableId>>(
|
|
534
|
+
cellId: RootCellId,
|
|
535
|
+
): CellOrUndefined<Schema, RootTableId, RootCellId>;
|
|
372
536
|
/**
|
|
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.
|
|
537
|
+
* When called with two parameters, this function will return the value of
|
|
538
|
+
* the specified Cell from a Table that has been joined in the query, for
|
|
539
|
+
* the Row being selected or filtered.
|
|
376
540
|
*
|
|
377
541
|
* @param joinedTableId The Id of the Table to fetch the value from. If the
|
|
378
542
|
* underlying Table was joined 'as' a different Id, that should instead be
|
|
@@ -380,7 +544,20 @@ export type GetTableCell = {
|
|
|
380
544
|
* @param joinedCellId The Id of the Cell to fetch the value for.
|
|
381
545
|
* @returns A Cell value or `undefined`.
|
|
382
546
|
*/
|
|
383
|
-
|
|
547
|
+
<
|
|
548
|
+
JoinedTableId extends TableIdFromSchema<Schema> | Id,
|
|
549
|
+
JoinedCellId extends JoinedCellIdOrId<
|
|
550
|
+
Schema,
|
|
551
|
+
JoinedTableId
|
|
552
|
+
> = JoinedCellIdOrId<Schema, JoinedTableId>,
|
|
553
|
+
>(
|
|
554
|
+
joinedTableId: JoinedTableId,
|
|
555
|
+
joinedCellId: JoinedCellId,
|
|
556
|
+
):
|
|
557
|
+
| (JoinedTableId extends TableIdFromSchema<Schema>
|
|
558
|
+
? Cell<Schema, JoinedTableId, JoinedCellId>
|
|
559
|
+
: Cell<any, any, any>)
|
|
560
|
+
| undefined;
|
|
384
561
|
};
|
|
385
562
|
|
|
386
563
|
/**
|
|
@@ -480,16 +657,21 @@ export type GetTableCell = {
|
|
|
480
657
|
* @category Definition
|
|
481
658
|
* @since v2.0.0
|
|
482
659
|
*/
|
|
483
|
-
export type Select
|
|
660
|
+
export type Select<
|
|
661
|
+
Schema extends OptionalTablesSchema,
|
|
662
|
+
RootTableId extends TableIdFromSchema<Schema>,
|
|
663
|
+
> = {
|
|
484
664
|
/**
|
|
485
665
|
* 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
|
|
666
|
+
* should select the value of the specified Cell from the query's root Table.
|
|
487
667
|
*
|
|
488
668
|
* @param cellId The Id of the Cell to fetch the value for.
|
|
489
669
|
* @returns A SelectedAs object so that the selected Cell Id can be optionally
|
|
490
670
|
* aliased.
|
|
491
671
|
*/
|
|
492
|
-
|
|
672
|
+
<RootCellId extends CellIdFromSchema<Schema, RootTableId>>(
|
|
673
|
+
cellId: RootCellId,
|
|
674
|
+
): SelectedAs;
|
|
493
675
|
/**
|
|
494
676
|
* Calling this function with two parameters will indicate that the query
|
|
495
677
|
* should select the value of the specified Cell from a Table that has been
|
|
@@ -502,11 +684,14 @@ export type Select = {
|
|
|
502
684
|
* @returns A SelectedAs object so that the selected Cell Id can be optionally
|
|
503
685
|
* aliased.
|
|
504
686
|
*/
|
|
505
|
-
|
|
687
|
+
<JoinedTableId extends TableIdFromSchema<Schema> | Id>(
|
|
688
|
+
joinedTableId: JoinedTableId,
|
|
689
|
+
joinedCellId: JoinedCellIdOrId<Schema, JoinedTableId>,
|
|
690
|
+
): SelectedAs;
|
|
506
691
|
/**
|
|
507
692
|
* Calling this function with one callback parameter will indicate that the
|
|
508
693
|
* query should select a calculated value, based on one or more Cell values in
|
|
509
|
-
* the
|
|
694
|
+
* the root Table or a joined Table, or on the root Table's Row Id.
|
|
510
695
|
*
|
|
511
696
|
* @param getCell A callback that takes a GetTableCell function and the main
|
|
512
697
|
* Table's Row Id. These can be used to programmatically create a calculated
|
|
@@ -515,9 +700,13 @@ export type Select = {
|
|
|
515
700
|
* aliased.
|
|
516
701
|
*/
|
|
517
702
|
(
|
|
518
|
-
getCell: (
|
|
703
|
+
getCell: (
|
|
704
|
+
getTableCell: GetTableCell<Schema, RootTableId>,
|
|
705
|
+
rowId: Id,
|
|
706
|
+
) => ResultCellOrUndefined,
|
|
519
707
|
): SelectedAs;
|
|
520
708
|
};
|
|
709
|
+
|
|
521
710
|
/**
|
|
522
711
|
* The SelectedAs type describes an object returned from calling a Select
|
|
523
712
|
* function so that the selected Cell Id can be optionally aliased.
|
|
@@ -588,11 +777,11 @@ export type SelectedAs = {
|
|
|
588
777
|
* distant join Table.
|
|
589
778
|
*
|
|
590
779
|
* 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
|
|
780
|
+
* Table will be joined to each Row of the root Table, queries follow the 'left
|
|
592
781
|
* join' semantics you may be familiar with from SQL. This means that an
|
|
593
782
|
* unfiltered query will only ever return the same number of Rows as the main
|
|
594
783
|
* Table being queried, and indeed the resulting table (assuming it has not been
|
|
595
|
-
* aggregated) will even preserve the
|
|
784
|
+
* aggregated) will even preserve the root Table's original Row Ids.
|
|
596
785
|
*
|
|
597
786
|
* @example
|
|
598
787
|
* This example shows a query that joins a single Table by using an Id present
|
|
@@ -630,7 +819,7 @@ export type SelectedAs = {
|
|
|
630
819
|
* This example shows a query that joins the same underlying Table twice, and
|
|
631
820
|
* aliases them (and the selected Cell Ids). Note the left-join semantics: Felix
|
|
632
821
|
* the cat was bought, but the seller was unknown. The record still exists in
|
|
633
|
-
* the
|
|
822
|
+
* the ResultTable.
|
|
634
823
|
*
|
|
635
824
|
* ```js
|
|
636
825
|
* const store = createStore()
|
|
@@ -663,7 +852,7 @@ export type SelectedAs = {
|
|
|
663
852
|
* ```
|
|
664
853
|
* @example
|
|
665
854
|
* This example shows a query that calculates the Id of the joined Table based
|
|
666
|
-
* from multiple values in the
|
|
855
|
+
* from multiple values in the root Table rather than a single Cell.
|
|
667
856
|
*
|
|
668
857
|
* ```js
|
|
669
858
|
* const store = createStore()
|
|
@@ -738,34 +927,40 @@ export type SelectedAs = {
|
|
|
738
927
|
* @category Definition
|
|
739
928
|
* @since v2.0.0
|
|
740
929
|
*/
|
|
741
|
-
export type Join
|
|
930
|
+
export type Join<
|
|
931
|
+
Schema extends OptionalTablesSchema,
|
|
932
|
+
RootTableId extends TableIdFromSchema<Schema>,
|
|
933
|
+
> = {
|
|
742
934
|
/**
|
|
743
935
|
* Calling this function with two Id parameters will indicate that the join to
|
|
744
936
|
* a Row in an adjacent Table is made by finding its Id in a Cell of the
|
|
745
|
-
* query's
|
|
937
|
+
* query's root Table.
|
|
746
938
|
*
|
|
747
939
|
* @param joinedTableId The Id of the Table to join to.
|
|
748
|
-
* @param on The Id of the Cell in the
|
|
940
|
+
* @param on The Id of the Cell in the root Table that contains the joined
|
|
749
941
|
* Table's Row Id.
|
|
750
942
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
751
943
|
* aliased.
|
|
752
944
|
*/
|
|
753
|
-
(
|
|
945
|
+
(
|
|
946
|
+
joinedTableId: TableIdFromSchema<Schema>,
|
|
947
|
+
on: CellIdFromSchema<Schema, RootTableId>,
|
|
948
|
+
): JoinedAs;
|
|
754
949
|
/**
|
|
755
950
|
* Calling this function with two parameters (where the second is a function)
|
|
756
951
|
* 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
|
|
952
|
+
* calculating its Id from the Cells and the Row Id of the query's root Table.
|
|
758
953
|
*
|
|
759
954
|
* @param joinedTableId The Id of the Table to join to.
|
|
760
|
-
* @param on A callback that takes a GetCell function and the
|
|
955
|
+
* @param on A callback that takes a GetCell function and the root Table's Row
|
|
761
956
|
* Id. These can be used to programmatically calculate the joined Table's Row
|
|
762
957
|
* Id.
|
|
763
958
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
764
959
|
* aliased.
|
|
765
960
|
*/
|
|
766
961
|
(
|
|
767
|
-
joinedTableId:
|
|
768
|
-
on: (getCell: GetCell, rowId: Id) => Id | undefined,
|
|
962
|
+
joinedTableId: TableIdFromSchema<Schema>,
|
|
963
|
+
on: (getCell: GetCell<Schema, RootTableId>, rowId: Id) => Id | undefined,
|
|
769
964
|
): JoinedAs;
|
|
770
965
|
/**
|
|
771
966
|
* Calling this function with three Id parameters will indicate that the join
|
|
@@ -781,7 +976,19 @@ export type Join = {
|
|
|
781
976
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
782
977
|
* aliased.
|
|
783
978
|
*/
|
|
784
|
-
|
|
979
|
+
<
|
|
980
|
+
IntermediateJoinedTableId extends TableIdFromSchema<Schema> | Id =
|
|
981
|
+
| TableIdFromSchema<Schema>
|
|
982
|
+
| Id,
|
|
983
|
+
IntermediateJoinedCellId extends JoinedCellIdOrId<
|
|
984
|
+
Schema,
|
|
985
|
+
IntermediateJoinedTableId
|
|
986
|
+
> = JoinedCellIdOrId<Schema, IntermediateJoinedTableId>,
|
|
987
|
+
>(
|
|
988
|
+
joinedTableId: TableIdFromSchema<Schema>,
|
|
989
|
+
fromIntermediateJoinedTableId: IntermediateJoinedTableId,
|
|
990
|
+
on: IntermediateJoinedCellId,
|
|
991
|
+
): JoinedAs;
|
|
785
992
|
/**
|
|
786
993
|
* Calling this function with three parameters (where the third is a function)
|
|
787
994
|
* will indicate that the join to a Row in distant Table is made by
|
|
@@ -798,15 +1005,24 @@ export type Join = {
|
|
|
798
1005
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
799
1006
|
* aliased.
|
|
800
1007
|
*/
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
1008
|
+
<
|
|
1009
|
+
IntermediateJoinedTableId extends TableIdFromSchema<Schema> | Id =
|
|
1010
|
+
| TableIdFromSchema<Schema>
|
|
1011
|
+
| Id,
|
|
1012
|
+
>(
|
|
1013
|
+
joinedTableId: TableIdFromSchema<Schema>,
|
|
1014
|
+
fromIntermediateJoinedTableId: IntermediateJoinedTableId,
|
|
804
1015
|
on: (
|
|
805
|
-
|
|
806
|
-
|
|
1016
|
+
// prettier-ignore
|
|
1017
|
+
getIntermediateJoinedCell:
|
|
1018
|
+
IntermediateJoinedTableId extends TableIdFromSchema<Schema>
|
|
1019
|
+
? GetCell<Schema, IntermediateJoinedTableId>
|
|
1020
|
+
: GetCell<NoTablesSchema, Id>,
|
|
1021
|
+
intermediateJoinedRowId: Id,
|
|
807
1022
|
) => Id | undefined,
|
|
808
1023
|
): JoinedAs;
|
|
809
1024
|
};
|
|
1025
|
+
|
|
810
1026
|
/**
|
|
811
1027
|
* The JoinedAs type describes an object returned from calling a Join function
|
|
812
1028
|
* so that the joined Table Id can be optionally aliased.
|
|
@@ -815,6 +1031,9 @@ export type Join = {
|
|
|
815
1031
|
* create two joins to the same underlying Table, both _without_ aliases), only
|
|
816
1032
|
* the latter of two will be used in the query.
|
|
817
1033
|
*
|
|
1034
|
+
* For the purposes of clarity, it's recommended to use an alias that does not
|
|
1035
|
+
* collide with a real underlying Table (whether included in the query or not).
|
|
1036
|
+
*
|
|
818
1037
|
* @example
|
|
819
1038
|
* This example shows a query that joins the same underlying Table twice, for
|
|
820
1039
|
* different purposes. Both joins are aliased with the 'as' function to
|
|
@@ -852,17 +1071,22 @@ export type Join = {
|
|
|
852
1071
|
* @category Definition
|
|
853
1072
|
* @since v2.0.0
|
|
854
1073
|
*/
|
|
855
|
-
export type JoinedAs = {
|
|
1074
|
+
export type JoinedAs = {
|
|
1075
|
+
/**
|
|
1076
|
+
* A function that lets you specify an alias for the joined Table Id.
|
|
1077
|
+
*/
|
|
1078
|
+
as: (joinedTableId: Id) => void;
|
|
1079
|
+
};
|
|
856
1080
|
|
|
857
1081
|
/**
|
|
858
1082
|
* The Where type describes a function that lets you specify conditions to
|
|
859
|
-
* filter results, based on the underlying Cells of the
|
|
1083
|
+
* filter results, based on the underlying Cells of the root or joined Tables.
|
|
860
1084
|
*
|
|
861
1085
|
* The Where function is provided to the third `query` parameter of the
|
|
862
1086
|
* setQueryDefinition method.
|
|
863
1087
|
*
|
|
864
1088
|
* If you do not specify a Where clause, you should expect every non-empty Row
|
|
865
|
-
* of the
|
|
1089
|
+
* of the root Table to appear in the query's results.
|
|
866
1090
|
*
|
|
867
1091
|
* A Where condition has to be true for a Row to be included in the results.
|
|
868
1092
|
* Each Where class is additive, as though combined with a logical 'and'. If you
|
|
@@ -970,17 +1194,23 @@ export type JoinedAs = {as: (joinedTableId: Id) => void};
|
|
|
970
1194
|
* @category Definition
|
|
971
1195
|
* @since v2.0.0
|
|
972
1196
|
*/
|
|
973
|
-
export type Where
|
|
1197
|
+
export type Where<
|
|
1198
|
+
Schema extends OptionalTablesSchema,
|
|
1199
|
+
RootTableId extends TableIdFromSchema<Schema>,
|
|
1200
|
+
> = {
|
|
974
1201
|
/**
|
|
975
1202
|
* Calling this function with two parameters is used to include only those
|
|
976
|
-
* Rows for which a specified Cell in the query's
|
|
1203
|
+
* Rows for which a specified Cell in the query's root Table has a specified
|
|
977
1204
|
* value.
|
|
978
1205
|
*
|
|
979
|
-
* @param cellId The Id of the Cell in the query's
|
|
1206
|
+
* @param cellId The Id of the Cell in the query's root Table to test.
|
|
980
1207
|
* @param equals The value that the Cell has to have for the Row to be
|
|
981
1208
|
* included in the result.
|
|
982
1209
|
*/
|
|
983
|
-
|
|
1210
|
+
<RootCellId extends CellIdFromSchema<Schema, RootTableId>>(
|
|
1211
|
+
cellId: RootCellId,
|
|
1212
|
+
equals: Cell<Schema, RootTableId, RootCellId>,
|
|
1213
|
+
): void;
|
|
984
1214
|
/**
|
|
985
1215
|
* Calling this function with three parameters is used to include only those
|
|
986
1216
|
* Rows for which a specified Cell in a joined Table has a specified value.
|
|
@@ -992,7 +1222,22 @@ export type Where = {
|
|
|
992
1222
|
* @param equals The value that the Cell has to have for the Row to be
|
|
993
1223
|
* included in the result.
|
|
994
1224
|
*/
|
|
995
|
-
|
|
1225
|
+
<
|
|
1226
|
+
JoinedTableId extends TableIdFromSchema<Schema> | Id,
|
|
1227
|
+
JoinedCellId extends JoinedCellIdOrId<
|
|
1228
|
+
Schema,
|
|
1229
|
+
JoinedTableId
|
|
1230
|
+
> = JoinedCellIdOrId<Schema, JoinedTableId>,
|
|
1231
|
+
JoinedCell extends Cell<Schema, JoinedTableId, JoinedCellId> = Cell<
|
|
1232
|
+
Schema,
|
|
1233
|
+
JoinedTableId,
|
|
1234
|
+
JoinedCellId
|
|
1235
|
+
>,
|
|
1236
|
+
>(
|
|
1237
|
+
joinedTableId: JoinedTableId,
|
|
1238
|
+
joinedCellId: JoinedCellId,
|
|
1239
|
+
equals: JoinedCell,
|
|
1240
|
+
): void;
|
|
996
1241
|
/**
|
|
997
1242
|
* Calling this function with one callback parameter is used to include only
|
|
998
1243
|
* those Rows which meet a calculated boolean condition, based on values in
|
|
@@ -1001,12 +1246,14 @@ export type Where = {
|
|
|
1001
1246
|
* @param condition A callback that takes a GetTableCell function and that
|
|
1002
1247
|
* should return `true` for the Row to be included in the result.
|
|
1003
1248
|
*/
|
|
1004
|
-
(
|
|
1249
|
+
(
|
|
1250
|
+
condition: (getTableCell: GetTableCell<Schema, RootTableId>) => boolean,
|
|
1251
|
+
): void;
|
|
1005
1252
|
};
|
|
1006
1253
|
|
|
1007
1254
|
/**
|
|
1008
1255
|
* The Group type describes a function that lets you specify that the values of
|
|
1009
|
-
* a Cell in multiple
|
|
1256
|
+
* a Cell in multiple ResultRows should be aggregated together.
|
|
1010
1257
|
*
|
|
1011
1258
|
* The Group function is provided to the third `query` parameter of the
|
|
1012
1259
|
* setQueryDefinition method. When called, it should refer to a Cell Id (or
|
|
@@ -1046,7 +1293,7 @@ export type Where = {
|
|
|
1046
1293
|
* input values - for example, when a Row is added to the Table.
|
|
1047
1294
|
* @param aggregateRemove A function that can be used to optimize a custom
|
|
1048
1295
|
* Aggregate by providing a shortcut for when a single value is removed from the
|
|
1049
|
-
* input values - for example
|
|
1296
|
+
* input values - for example, when a Row is removed from the Table.
|
|
1050
1297
|
* @param aggregateReplace A function that can be used to optimize a custom
|
|
1051
1298
|
* Aggregate by providing a shortcut for when a single value in the input values
|
|
1052
1299
|
* is replaced with another - for example, when a Row is updated.
|
|
@@ -1183,6 +1430,7 @@ export type Group = (
|
|
|
1183
1430
|
aggregateRemove?: AggregateRemove,
|
|
1184
1431
|
aggregateReplace?: AggregateReplace,
|
|
1185
1432
|
) => GroupedAs;
|
|
1433
|
+
|
|
1186
1434
|
/**
|
|
1187
1435
|
* The GroupedAs type describes an object returned from calling a Group function
|
|
1188
1436
|
* so that the grouped Cell Id can be optionally aliased.
|
|
@@ -1221,7 +1469,12 @@ export type Group = (
|
|
|
1221
1469
|
* @category Definition
|
|
1222
1470
|
* @since v2.0.0
|
|
1223
1471
|
*/
|
|
1224
|
-
export type GroupedAs = {
|
|
1472
|
+
export type GroupedAs = {
|
|
1473
|
+
/**
|
|
1474
|
+
* A function that lets you specify an alias for the grouped Cell Id.
|
|
1475
|
+
*/
|
|
1476
|
+
as: (groupedCellId: Id) => void;
|
|
1477
|
+
};
|
|
1225
1478
|
|
|
1226
1479
|
/**
|
|
1227
1480
|
* The Having type describes a function that lets you specify conditions to
|
|
@@ -1314,14 +1567,14 @@ export type GroupedAs = {as: (groupedCellId: Id) => void};
|
|
|
1314
1567
|
export type Having = {
|
|
1315
1568
|
/**
|
|
1316
1569
|
* Calling this function with two parameters is used to include only those
|
|
1317
|
-
* Rows for which a specified Cell in the query's
|
|
1570
|
+
* Rows for which a specified Cell in the query's root Table has a specified
|
|
1318
1571
|
* value.
|
|
1319
1572
|
*
|
|
1320
1573
|
* @param selectedOrGroupedCellId The Id of the Cell in the query to test.
|
|
1321
1574
|
* @param equals The value that the Cell has to have for the Row to be
|
|
1322
1575
|
* included in the result.
|
|
1323
1576
|
*/
|
|
1324
|
-
(selectedOrGroupedCellId: Id, equals:
|
|
1577
|
+
(selectedOrGroupedCellId: Id, equals: ResultCell): void;
|
|
1325
1578
|
/**
|
|
1326
1579
|
* Calling this function with one callback parameter is used to include only
|
|
1327
1580
|
* those Rows which meet a calculated boolean condition.
|
|
@@ -1329,7 +1582,7 @@ export type Having = {
|
|
|
1329
1582
|
* @param condition A callback that takes a GetCell function and that should
|
|
1330
1583
|
* return `true` for the Row to be included in the result.
|
|
1331
1584
|
*/
|
|
1332
|
-
(condition: (getSelectedOrGroupedCell:
|
|
1585
|
+
(condition: (getSelectedOrGroupedCell: GetResultCell) => boolean): void;
|
|
1333
1586
|
};
|
|
1334
1587
|
|
|
1335
1588
|
/**
|
|
@@ -1429,16 +1682,16 @@ export type Having = {
|
|
|
1429
1682
|
* @category Queries
|
|
1430
1683
|
* @since v2.0.0
|
|
1431
1684
|
*/
|
|
1432
|
-
export interface Queries<Schemas extends OptionalSchemas
|
|
1685
|
+
export interface Queries<in out Schemas extends OptionalSchemas> {
|
|
1433
1686
|
/**
|
|
1434
1687
|
* The setQueryDefinition method lets you set the definition of a query.
|
|
1435
1688
|
*
|
|
1436
1689
|
* Every query definition is identified by a unique Id, and if you re-use an
|
|
1437
1690
|
* existing Id with this method, the previous definition is overwritten.
|
|
1438
1691
|
*
|
|
1439
|
-
* A query provides a tabular result formed from each Row within a
|
|
1440
|
-
* The definition must specify this
|
|
1441
|
-
*
|
|
1692
|
+
* A query provides a tabular result formed from each Row within a root Table.
|
|
1693
|
+
* The definition must specify this Table (by its Id) to be aggregated. Other
|
|
1694
|
+
* Tables can be joined to that using Join clauses.
|
|
1442
1695
|
*
|
|
1443
1696
|
* The third `query` parameter is a callback that you provide to define the
|
|
1444
1697
|
* query. That callback is provided with a `keywords` object that contains the
|
|
@@ -1454,7 +1707,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1454
1707
|
* filter results, based on the underlying Cells of the main or joined
|
|
1455
1708
|
* Tables.
|
|
1456
1709
|
* - The Group type describes a function that lets you specify that the values
|
|
1457
|
-
* of a Cell in multiple
|
|
1710
|
+
* of a Cell in multiple ResultRows should be aggregated together.
|
|
1458
1711
|
* - The Having type describes a function that lets you specify conditions to
|
|
1459
1712
|
* filter results, based on the grouped Cells resulting from a Group clause.
|
|
1460
1713
|
*
|
|
@@ -1465,7 +1718,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1465
1718
|
* addResultSortedRowIdsListener method to sort and paginate the results.
|
|
1466
1719
|
*
|
|
1467
1720
|
* @param queryId The Id of the query to define.
|
|
1468
|
-
* @param tableId The Id of the
|
|
1721
|
+
* @param tableId The Id of the root Table the query will be based on.
|
|
1469
1722
|
* @param query A callback which can take a `keywords` object and which uses
|
|
1470
1723
|
the functions it contains to define the query.
|
|
1471
1724
|
* @returns A reference to the Queries object.
|
|
@@ -1493,13 +1746,13 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1493
1746
|
* @category Configuration
|
|
1494
1747
|
* @since v2.0.0
|
|
1495
1748
|
*/
|
|
1496
|
-
setQueryDefinition(
|
|
1749
|
+
setQueryDefinition<RootTableId extends TableIdFromSchema<Schemas[0]>>(
|
|
1497
1750
|
queryId: Id,
|
|
1498
|
-
tableId:
|
|
1751
|
+
tableId: RootTableId,
|
|
1499
1752
|
query: (keywords: {
|
|
1500
|
-
select: Select
|
|
1501
|
-
join: Join
|
|
1502
|
-
where: Where
|
|
1753
|
+
select: Select<Schemas[0], RootTableId>;
|
|
1754
|
+
join: Join<Schemas[0], RootTableId>;
|
|
1755
|
+
where: Where<Schemas[0], RootTableId>;
|
|
1503
1756
|
group: Group;
|
|
1504
1757
|
having: Having;
|
|
1505
1758
|
}) => void,
|
|
@@ -1686,11 +1939,13 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1686
1939
|
* @category Getter
|
|
1687
1940
|
* @since v2.0.0
|
|
1688
1941
|
*/
|
|
1689
|
-
getTableId
|
|
1942
|
+
getTableId<TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
1943
|
+
queryId: Id,
|
|
1944
|
+
): TableId | undefined;
|
|
1690
1945
|
|
|
1691
1946
|
/**
|
|
1692
1947
|
* The getResultTable method returns an object containing the entire data of
|
|
1693
|
-
* the
|
|
1948
|
+
* the ResultTable of the given query.
|
|
1694
1949
|
*
|
|
1695
1950
|
* This has the same behavior as a Store's getTable method. For example, if
|
|
1696
1951
|
* the query Id is invalid, the method returns an empty object. Similarly, it
|
|
@@ -1699,13 +1954,13 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1699
1954
|
* themselves.
|
|
1700
1955
|
*
|
|
1701
1956
|
* @param queryId The Id of a query.
|
|
1702
|
-
* @returns An object containing the entire data of the
|
|
1957
|
+
* @returns An object containing the entire data of the ResultTable of the
|
|
1703
1958
|
* query.
|
|
1704
|
-
* @returns The result of the query, structured as a
|
|
1959
|
+
* @returns The result of the query, structured as a ResultTable.
|
|
1705
1960
|
* @example
|
|
1706
1961
|
* This example creates a Queries object, a single query definition, and then
|
|
1707
1962
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1708
|
-
*
|
|
1963
|
+
* ResultTable.
|
|
1709
1964
|
*
|
|
1710
1965
|
* ```js
|
|
1711
1966
|
* const store = createStore().setTable('pets', {
|
|
@@ -1732,11 +1987,11 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1732
1987
|
* @category Result
|
|
1733
1988
|
* @since v2.0.0
|
|
1734
1989
|
*/
|
|
1735
|
-
getResultTable(queryId: Id):
|
|
1990
|
+
getResultTable(queryId: Id): ResultTable;
|
|
1736
1991
|
|
|
1737
1992
|
/**
|
|
1738
|
-
* The getResultRowIds method returns the Ids of every
|
|
1739
|
-
* of the given query.
|
|
1993
|
+
* The getResultRowIds method returns the Ids of every ResultRow in the
|
|
1994
|
+
* ResultTable of the given query.
|
|
1740
1995
|
*
|
|
1741
1996
|
* This has the same behavior as a Store's getRowIds method. For example, if
|
|
1742
1997
|
* the query Id is invalid, the method returns an empty array. Similarly, it
|
|
@@ -1744,11 +1999,11 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1744
1999
|
* made to the list object are not made to the query results themselves.
|
|
1745
2000
|
*
|
|
1746
2001
|
* @param queryId The Id of a query.
|
|
1747
|
-
* @returns An array of the Ids of every
|
|
2002
|
+
* @returns An array of the Ids of every ResultRow in the result of the query.
|
|
1748
2003
|
* @example
|
|
1749
2004
|
* This example creates a Queries object, a single query definition, and then
|
|
1750
2005
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1751
|
-
*
|
|
2006
|
+
* ResultRow Ids.
|
|
1752
2007
|
*
|
|
1753
2008
|
* ```js
|
|
1754
2009
|
* const store = createStore().setTable('pets', {
|
|
@@ -1778,37 +2033,37 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1778
2033
|
getResultRowIds(queryId: Id): Ids;
|
|
1779
2034
|
|
|
1780
2035
|
/**
|
|
1781
|
-
* The getResultSortedRowIds method returns the Ids of every
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
2036
|
+
* The getResultSortedRowIds method returns the Ids of every ResultRow in the
|
|
2037
|
+
* ResultTable of the given query, sorted according to the values in a
|
|
2038
|
+
* specified ResultCell.
|
|
1784
2039
|
*
|
|
1785
2040
|
* This has the same behavior as a Store's getSortedRowIds method. For
|
|
1786
2041
|
* example, if the query Id is invalid, the method returns an empty array.
|
|
1787
2042
|
* Similarly, the sorting of the rows is alphanumeric, and you can indicate
|
|
1788
2043
|
* whether it should be in descending order. The `offset` and `limit`
|
|
1789
2044
|
* parameters are used to paginate results, but default to `0` and `undefined`
|
|
1790
|
-
* to return all available
|
|
2045
|
+
* to return all available ResultRow Ids if not specified.
|
|
1791
2046
|
*
|
|
1792
2047
|
* Note that every call to this method will perform the sorting afresh - there
|
|
1793
2048
|
* 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.
|
|
2049
|
+
* results yourself, especially when the ResultTable is large. For a
|
|
2050
|
+
* performant approach to tracking the sorted ResultRow Ids when they change,
|
|
2051
|
+
* use the addResultSortedRowIdsListener method.
|
|
1797
2052
|
*
|
|
1798
2053
|
* @param queryId The Id of a query.
|
|
1799
|
-
* @param cellId The Id of the
|
|
1800
|
-
* `undefined` to by sort the
|
|
2054
|
+
* @param cellId The Id of the ResultCell whose values are used for the
|
|
2055
|
+
* sorting, or `undefined` to by sort the ResultRow Id itself.
|
|
1801
2056
|
* @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
|
|
2057
|
+
* @param offset The number of ResultRow Ids to skip for pagination purposes,
|
|
2058
|
+
* if any.
|
|
2059
|
+
* @param limit The maximum number of ResultRow Ids to return, or `undefined`
|
|
2060
|
+
* for all.
|
|
2061
|
+
* @returns An array of the sorted Ids of every ResultRow in the result of the
|
|
1807
2062
|
* query.
|
|
1808
2063
|
* @example
|
|
1809
2064
|
* This example creates a Queries object, a single query definition, and then
|
|
1810
2065
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1811
|
-
*
|
|
2066
|
+
* ResultRow Ids.
|
|
1812
2067
|
*
|
|
1813
2068
|
* ```js
|
|
1814
2069
|
* const store = createStore().setTable('pets', {
|
|
@@ -1845,22 +2100,22 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1845
2100
|
|
|
1846
2101
|
/**
|
|
1847
2102
|
* The getResultRow method returns an object containing the entire data of a
|
|
1848
|
-
* single
|
|
2103
|
+
* single ResultRow in the ResultTable of the given query.
|
|
1849
2104
|
*
|
|
1850
2105
|
* 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.
|
|
2106
|
+
* query or ResultRow Id is invalid, the method returns an empty object.
|
|
2107
|
+
* Similarly, it returns a copy of, rather than a reference to the underlying
|
|
2108
|
+
* data, so changes made to the returned object are not made to the query
|
|
2109
|
+
* results themselves.
|
|
1855
2110
|
*
|
|
1856
2111
|
* @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
|
-
*
|
|
2112
|
+
* @param rowId The Id of the ResultRow in the ResultTable.
|
|
2113
|
+
* @returns An object containing the entire data of the ResultRow in the
|
|
2114
|
+
* ResultTable of the query.
|
|
1860
2115
|
* @example
|
|
1861
2116
|
* 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
|
-
*
|
|
2117
|
+
* calls this method on it (as well as a non-existent ResultRow Id) to get
|
|
2118
|
+
* the ResultRow.
|
|
1864
2119
|
*
|
|
1865
2120
|
* ```js
|
|
1866
2121
|
* const store = createStore().setTable('pets', {
|
|
@@ -1887,26 +2142,26 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1887
2142
|
* @category Result
|
|
1888
2143
|
* @since v2.0.0
|
|
1889
2144
|
*/
|
|
1890
|
-
getResultRow(queryId: Id, rowId: Id):
|
|
2145
|
+
getResultRow(queryId: Id, rowId: Id): ResultRow;
|
|
1891
2146
|
|
|
1892
2147
|
/**
|
|
1893
|
-
* The getResultCellIds method returns the Ids of every
|
|
1894
|
-
* in the
|
|
2148
|
+
* The getResultCellIds method returns the Ids of every ResultCell in a given
|
|
2149
|
+
* ResultRow, in the ResultTable of the given query.
|
|
1895
2150
|
*
|
|
1896
2151
|
* This has the same behavior as a Store's getCellIds method. For example, if
|
|
1897
|
-
* the query Id or
|
|
2152
|
+
* the query Id or ResultRow Id is invalid, the method returns an empty array.
|
|
1898
2153
|
* Similarly, it returns a copy of, rather than a reference to the list of
|
|
1899
2154
|
* Ids, so changes made to the list object are not made to the query results
|
|
1900
2155
|
* themselves.
|
|
1901
2156
|
*
|
|
1902
2157
|
* @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.
|
|
2158
|
+
* @param rowId The Id of the ResultRow in the ResultTable.
|
|
2159
|
+
* @returns An array of the Ids of every ResultCell in the ResultRow in the
|
|
2160
|
+
* result of the query.
|
|
1906
2161
|
* @example
|
|
1907
2162
|
* 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
|
-
*
|
|
2163
|
+
* calls this method on it (as well as a non-existent ResultRow Id) to get the
|
|
2164
|
+
* ResultCell Ids.
|
|
1910
2165
|
*
|
|
1911
2166
|
* ```js
|
|
1912
2167
|
* const store = createStore().setTable('pets', {
|
|
@@ -1936,20 +2191,21 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1936
2191
|
getResultCellIds(queryId: Id, rowId: Id): Ids;
|
|
1937
2192
|
|
|
1938
2193
|
/**
|
|
1939
|
-
* The getResultCell method returns the value of a single
|
|
1940
|
-
* in the
|
|
2194
|
+
* The getResultCell method returns the value of a single ResultCell in a
|
|
2195
|
+
* given ResultRow, in the ResultTable of the given query.
|
|
1941
2196
|
*
|
|
1942
2197
|
* This has the same behavior as a Store's getCell method. For example, if the
|
|
1943
|
-
* query, or
|
|
2198
|
+
* query, or ResultRow, or ResultCell Id is invalid, the method returns
|
|
2199
|
+
* `undefined`.
|
|
1944
2200
|
*
|
|
1945
2201
|
* @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
|
|
2202
|
+
* @param rowId The Id of the ResultRow in the ResultTable.
|
|
2203
|
+
* @param cellId The Id of the ResultCell in the ResultRow.
|
|
2204
|
+
* @returns The value of the ResultCell, or `undefined`.
|
|
1949
2205
|
* @example
|
|
1950
2206
|
* 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
|
-
*
|
|
2207
|
+
* calls this method on it (as well as a non-existent ResultCell Id) to get
|
|
2208
|
+
* the ResultCell.
|
|
1953
2209
|
*
|
|
1954
2210
|
* ```js
|
|
1955
2211
|
* const store = createStore().setTable('pets', {
|
|
@@ -1976,16 +2232,16 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
1976
2232
|
* @category Result
|
|
1977
2233
|
* @since v2.0.0
|
|
1978
2234
|
*/
|
|
1979
|
-
getResultCell(queryId: Id, rowId: Id, cellId: Id):
|
|
2235
|
+
getResultCell(queryId: Id, rowId: Id, cellId: Id): ResultCellOrUndefined;
|
|
1980
2236
|
|
|
1981
2237
|
/**
|
|
1982
2238
|
* The hasResultTable method returns a boolean indicating whether a given
|
|
1983
|
-
*
|
|
2239
|
+
* ResultTable exists.
|
|
1984
2240
|
*
|
|
1985
2241
|
* @param queryId The Id of a possible query.
|
|
1986
|
-
* @returns Whether a
|
|
2242
|
+
* @returns Whether a ResultTable for that query Id exists.
|
|
1987
2243
|
* @example
|
|
1988
|
-
* This example shows two simple
|
|
2244
|
+
* This example shows two simple ResultTable existence checks.
|
|
1989
2245
|
*
|
|
1990
2246
|
* ```js
|
|
1991
2247
|
* const store = createStore().setTable('pets', {
|
|
@@ -2014,14 +2270,14 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2014
2270
|
hasResultTable(queryId: Id): boolean;
|
|
2015
2271
|
|
|
2016
2272
|
/**
|
|
2017
|
-
* The hasResultRow method returns a boolean indicating whether a given
|
|
2018
|
-
*
|
|
2273
|
+
* The hasResultRow method returns a boolean indicating whether a given
|
|
2274
|
+
* ResultRow exists.
|
|
2019
2275
|
*
|
|
2020
2276
|
* @param queryId The Id of a possible query.
|
|
2021
|
-
* @param rowId The Id of a possible
|
|
2022
|
-
* @returns Whether a
|
|
2277
|
+
* @param rowId The Id of a possible ResultRow.
|
|
2278
|
+
* @returns Whether a ResultRow for that Id exists.
|
|
2023
2279
|
* @example
|
|
2024
|
-
* This example shows two simple
|
|
2280
|
+
* This example shows two simple ResultRow existence checks.
|
|
2025
2281
|
*
|
|
2026
2282
|
* ```js
|
|
2027
2283
|
* const store = createStore().setTable('pets', {
|
|
@@ -2051,14 +2307,14 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2051
2307
|
|
|
2052
2308
|
/**
|
|
2053
2309
|
* The hasResultCell method returns a boolean indicating whether a given
|
|
2054
|
-
*
|
|
2310
|
+
* ResultCell exists.
|
|
2055
2311
|
*
|
|
2056
2312
|
* @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
|
|
2313
|
+
* @param rowId The Id of a possible ResultRow.
|
|
2314
|
+
* @param cellId The Id of a possible ResultCell.
|
|
2315
|
+
* @returns Whether a ResultCell for that Id exists.
|
|
2060
2316
|
* @example
|
|
2061
|
-
* This example shows two simple
|
|
2317
|
+
* This example shows two simple ResultRow existence checks.
|
|
2062
2318
|
*
|
|
2063
2319
|
* ```js
|
|
2064
2320
|
* const store = createStore().setTable('pets', {
|
|
@@ -2088,18 +2344,18 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2088
2344
|
|
|
2089
2345
|
/**
|
|
2090
2346
|
* The forEachResultTable method takes a function that it will then call for
|
|
2091
|
-
* each
|
|
2347
|
+
* each ResultTable in the Queries object.
|
|
2092
2348
|
*
|
|
2093
|
-
* This method is useful for iterating over all the
|
|
2349
|
+
* This method is useful for iterating over all the ResultTables of the
|
|
2094
2350
|
* queries in a functional style. The `tableCallback` parameter is a
|
|
2095
|
-
*
|
|
2096
|
-
*
|
|
2097
|
-
* of the
|
|
2351
|
+
* ResultTableCallback function that will be called with the Id of each
|
|
2352
|
+
* ResultTable, and with a function that can then be used to iterate over each
|
|
2353
|
+
* ResultRow of the ResultTable, should you wish.
|
|
2098
2354
|
*
|
|
2099
2355
|
* @param tableCallback The function that should be called for every query's
|
|
2100
|
-
*
|
|
2356
|
+
* ResultTable.
|
|
2101
2357
|
* @example
|
|
2102
|
-
* This example iterates over each query's
|
|
2358
|
+
* This example iterates over each query's ResultTable in a Queries object.
|
|
2103
2359
|
*
|
|
2104
2360
|
* ```js
|
|
2105
2361
|
* const store = createStore().setTable('pets', {
|
|
@@ -2131,23 +2387,23 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2131
2387
|
* @category Iterator
|
|
2132
2388
|
* @since v2.0.0
|
|
2133
2389
|
*/
|
|
2134
|
-
forEachResultTable(tableCallback:
|
|
2390
|
+
forEachResultTable(tableCallback: ResultTableCallback): void;
|
|
2135
2391
|
|
|
2136
2392
|
/**
|
|
2137
2393
|
* The forEachResultRow method takes a function that it will then call for
|
|
2138
|
-
* each
|
|
2394
|
+
* each ResultRow in the ResultTable of a query.
|
|
2139
2395
|
*
|
|
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
|
-
*
|
|
2396
|
+
* This method is useful for iterating over each ResultRow of the ResultTable
|
|
2397
|
+
* of the query in a functional style. The `rowCallback` parameter is a
|
|
2398
|
+
* ResultRowCallback function that will be called with the Id of each
|
|
2399
|
+
* ResultRow, and with a function that can then be used to iterate over each
|
|
2400
|
+
* ResultCell of the ResultRow, should you wish.
|
|
2145
2401
|
*
|
|
2146
2402
|
* @param queryId The Id of a query.
|
|
2147
|
-
* @param rowCallback The function that should be called for every
|
|
2148
|
-
* query's
|
|
2403
|
+
* @param rowCallback The function that should be called for every ResultRow
|
|
2404
|
+
* of the query's ResultTable.
|
|
2149
2405
|
* @example
|
|
2150
|
-
* This example iterates over each
|
|
2406
|
+
* This example iterates over each ResultRow in a query's ResultTable.
|
|
2151
2407
|
*
|
|
2152
2408
|
* ```js
|
|
2153
2409
|
* const store = createStore().setTable('pets', {
|
|
@@ -2177,22 +2433,23 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2177
2433
|
* @category Iterator
|
|
2178
2434
|
* @since v2.0.0
|
|
2179
2435
|
*/
|
|
2180
|
-
forEachResultRow(queryId: Id, rowCallback:
|
|
2436
|
+
forEachResultRow(queryId: Id, rowCallback: ResultRowCallback): void;
|
|
2181
2437
|
|
|
2182
2438
|
/**
|
|
2183
2439
|
* The forEachResultCell method takes a function that it will then call for
|
|
2184
|
-
* each
|
|
2440
|
+
* each ResultCell in the ResultRow of a query.
|
|
2185
2441
|
*
|
|
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
|
|
2442
|
+
* This method is useful for iterating over each ResultCell of the ResultRow
|
|
2443
|
+
* of the query in a functional style. The `cellCallback` parameter is a
|
|
2444
|
+
* ResultCellCallback function that will be called with the Id and value of
|
|
2445
|
+
* each ResultCell.
|
|
2189
2446
|
*
|
|
2190
2447
|
* @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
|
|
2448
|
+
* @param rowId The Id of a ResultRow in the query's ResultTable.
|
|
2449
|
+
* @param cellCallback The function that should be called for every ResultCell
|
|
2450
|
+
* of the query's ResultRow.
|
|
2194
2451
|
* @example
|
|
2195
|
-
* This example iterates over each
|
|
2452
|
+
* This example iterates over each ResultCell in a query's ResultRow.
|
|
2196
2453
|
*
|
|
2197
2454
|
* ```js
|
|
2198
2455
|
* const store = createStore().setTable('pets', {
|
|
@@ -2220,28 +2477,32 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2220
2477
|
* @category Iterator
|
|
2221
2478
|
* @since v2.0.0
|
|
2222
2479
|
*/
|
|
2223
|
-
forEachResultCell(
|
|
2480
|
+
forEachResultCell(
|
|
2481
|
+
queryId: Id,
|
|
2482
|
+
rowId: Id,
|
|
2483
|
+
cellCallback: ResultCellCallback,
|
|
2484
|
+
): void;
|
|
2224
2485
|
|
|
2225
2486
|
/**
|
|
2226
2487
|
* The addResultTableListener method registers a listener function with the
|
|
2227
|
-
* Queries object that will be called whenever data in a
|
|
2488
|
+
* Queries object that will be called whenever data in a ResultTable changes.
|
|
2228
2489
|
*
|
|
2229
2490
|
* 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.
|
|
2491
|
+
* with a reference to the Queries object, the Id of the ResultTable that
|
|
2492
|
+
* changed (which is also the query Id), and a GetCellResultChange function in
|
|
2493
|
+
* case you need to inspect any changes that occurred.
|
|
2233
2494
|
*
|
|
2234
|
-
* You can either listen to a single
|
|
2235
|
-
* the method's first parameter) or changes to any
|
|
2236
|
-
*
|
|
2495
|
+
* You can either listen to a single ResultTable (by specifying a query Id as
|
|
2496
|
+
* the method's first parameter) or changes to any ResultTable (by providing a
|
|
2497
|
+
* `null` wildcard).
|
|
2237
2498
|
*
|
|
2238
2499
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2239
2500
|
* @param listener The function that will be called whenever data in the
|
|
2240
|
-
* matching
|
|
2501
|
+
* matching ResultTable changes.
|
|
2241
2502
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2242
2503
|
* @example
|
|
2243
2504
|
* This example registers a listener that responds to any changes to a
|
|
2244
|
-
* specific
|
|
2505
|
+
* specific ResultTable.
|
|
2245
2506
|
*
|
|
2246
2507
|
* ```js
|
|
2247
2508
|
* const store = createStore().setTable('pets', {
|
|
@@ -2275,7 +2536,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2275
2536
|
* ```
|
|
2276
2537
|
* @example
|
|
2277
2538
|
* This example registers a listener that responds to any changes to any
|
|
2278
|
-
*
|
|
2539
|
+
* ResultTable.
|
|
2279
2540
|
*
|
|
2280
2541
|
* ```js
|
|
2281
2542
|
* const store = createStore().setTable('pets', {
|
|
@@ -2311,32 +2572,35 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2311
2572
|
* @category Listener
|
|
2312
2573
|
* @since v2.0.0
|
|
2313
2574
|
*/
|
|
2314
|
-
addResultTableListener(
|
|
2575
|
+
addResultTableListener(
|
|
2576
|
+
queryId: IdOrNull,
|
|
2577
|
+
listener: ResultTableListener<Schemas>,
|
|
2578
|
+
): Id;
|
|
2315
2579
|
|
|
2316
2580
|
/**
|
|
2317
2581
|
* The addResultRowIdsListener method registers a listener function with the
|
|
2318
|
-
* Queries object that will be called whenever the
|
|
2319
|
-
* change.
|
|
2582
|
+
* Queries object that will be called whenever the ResultRow Ids in a
|
|
2583
|
+
* ResultTable change.
|
|
2320
2584
|
*
|
|
2321
2585
|
* 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).
|
|
2586
|
+
* called with a reference to the Queries object and the Id of the ResultTable
|
|
2587
|
+
* that changed (which is also the query Id).
|
|
2324
2588
|
*
|
|
2325
|
-
* By default, such a listener is only called when a
|
|
2326
|
-
* removed from, the
|
|
2327
|
-
*
|
|
2589
|
+
* By default, such a listener is only called when a ResultRow is added to, or
|
|
2590
|
+
* removed from, the ResultTable. To listen to all changes in the ResultTable,
|
|
2591
|
+
* use the addResultTableListener method.
|
|
2328
2592
|
*
|
|
2329
|
-
* You can either listen to a single
|
|
2330
|
-
* the method's first parameter) or changes to any
|
|
2331
|
-
*
|
|
2593
|
+
* You can either listen to a single ResultTable (by specifying a query Id as
|
|
2594
|
+
* the method's first parameter) or changes to any ResultTable (by providing a
|
|
2595
|
+
* `null` wildcard).
|
|
2332
2596
|
*
|
|
2333
2597
|
* @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
|
|
2598
|
+
* @param listener The function that will be called whenever the ResultRow Ids
|
|
2599
|
+
* in the ResultTable change.
|
|
2336
2600
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2337
2601
|
* @example
|
|
2338
|
-
* This example registers a listener that responds to any change to the
|
|
2339
|
-
* Ids of a specific
|
|
2602
|
+
* This example registers a listener that responds to any change to the
|
|
2603
|
+
* ResultRow Ids of a specific ResultTable.
|
|
2340
2604
|
*
|
|
2341
2605
|
* ```js
|
|
2342
2606
|
* const store = createStore().setTable('pets', {
|
|
@@ -2369,8 +2633,8 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2369
2633
|
* store.delListener(listenerId);
|
|
2370
2634
|
* ```
|
|
2371
2635
|
* @example
|
|
2372
|
-
* This example registers a listener that responds to any change to the
|
|
2373
|
-
* Ids of any
|
|
2636
|
+
* This example registers a listener that responds to any change to the
|
|
2637
|
+
* ResultRow Ids of any ResultTable.
|
|
2374
2638
|
*
|
|
2375
2639
|
* ```js
|
|
2376
2640
|
* const store = createStore().setTable('pets', {
|
|
@@ -2408,50 +2672,50 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2408
2672
|
*/
|
|
2409
2673
|
addResultRowIdsListener(
|
|
2410
2674
|
queryId: IdOrNull,
|
|
2411
|
-
listener: ResultRowIdsListener
|
|
2675
|
+
listener: ResultRowIdsListener<Schemas>,
|
|
2412
2676
|
): Id;
|
|
2413
2677
|
|
|
2414
2678
|
/**
|
|
2415
2679
|
* The addResultSortedRowIdsListener method registers a listener function with
|
|
2416
2680
|
* the Queries object that will be called whenever sorted (and optionally,
|
|
2417
|
-
* paginated)
|
|
2681
|
+
* paginated) ResultRow Ids in a ResultTable change.
|
|
2418
2682
|
*
|
|
2419
2683
|
* 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
|
|
2684
|
+
* called with a reference to the Queries object, the Id of the ResultTable
|
|
2685
|
+
* whose ResultRow Ids sorting changed (which is also the query Id), the
|
|
2686
|
+
* ResultCell Id being used to sort them, whether descending or not, and the
|
|
2687
|
+
* offset and limit of the number of Ids returned, for pagination purposes. It
|
|
2688
|
+
* also receives the sorted array of Ids itself, so that you can use them in
|
|
2689
|
+
* the listener without the additional cost of an explicit call to
|
|
2426
2690
|
* getResultSortedRowIds
|
|
2427
2691
|
*
|
|
2428
|
-
* Such a listener is called when a
|
|
2429
|
-
* value in the specified
|
|
2430
|
-
* enough to change the sorting of the
|
|
2692
|
+
* Such a listener is called when a ResultRow is added or removed, but also
|
|
2693
|
+
* when a value in the specified ResultCell (somewhere in the ResultTable) has
|
|
2694
|
+
* changed enough to change the sorting of the ResultRow Ids.
|
|
2431
2695
|
*
|
|
2432
2696
|
* Unlike most other listeners, you cannot provide wildcards (due to the cost
|
|
2433
2697
|
* of detecting changes to the sorting). You can only listen to a single
|
|
2434
|
-
* specified
|
|
2698
|
+
* specified ResultTable, sorted by a single specified ResultCell.
|
|
2435
2699
|
*
|
|
2436
2700
|
* The sorting of the rows is alphanumeric, and you can indicate whether it
|
|
2437
2701
|
* should be in descending order. The `offset` and `limit` parameters are used
|
|
2438
2702
|
* to paginate results, but default to `0` and `undefined` to return all
|
|
2439
|
-
* available
|
|
2703
|
+
* available ResultRow Ids if not specified.
|
|
2440
2704
|
*
|
|
2441
2705
|
* @param queryId The Id of the query to listen to.
|
|
2442
|
-
* @param cellId The Id of the
|
|
2443
|
-
* `undefined` to by sort the
|
|
2706
|
+
* @param cellId The Id of the ResultCell whose values are used for the
|
|
2707
|
+
* sorting, or `undefined` to by sort the ResultRow Id itself.
|
|
2444
2708
|
* @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
|
|
2709
|
+
* @param offset The number of ResultRow Ids to skip for pagination purposes,
|
|
2710
|
+
* if any.
|
|
2711
|
+
* @param limit The maximum number of ResultRow Ids to return, or `undefined`
|
|
2712
|
+
* for all.
|
|
2713
|
+
* @param listener The function that will be called whenever the sorted
|
|
2714
|
+
* ResultRow Ids in the ResultTable change.
|
|
2451
2715
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2452
2716
|
* @example
|
|
2453
2717
|
* This example registers a listener that responds to any change to the sorted
|
|
2454
|
-
*
|
|
2718
|
+
* ResultRow Ids of a specific ResultTable.
|
|
2455
2719
|
*
|
|
2456
2720
|
* ```js
|
|
2457
2721
|
* const store = createStore().setTable('pets', {
|
|
@@ -2476,22 +2740,22 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2476
2740
|
* 0,
|
|
2477
2741
|
* undefined,
|
|
2478
2742
|
* (queries, tableId, cellId, descending, offset, limit, sortedRowIds) => {
|
|
2479
|
-
* console.log(`Sorted
|
|
2743
|
+
* console.log(`Sorted row Ids for dogColors result table changed`);
|
|
2480
2744
|
* console.log(sortedRowIds);
|
|
2481
2745
|
* // ^ cheaper than calling getResultSortedRowIds again
|
|
2482
2746
|
* },
|
|
2483
2747
|
* );
|
|
2484
2748
|
*
|
|
2485
2749
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'});
|
|
2486
|
-
* // -> 'Sorted
|
|
2750
|
+
* // -> 'Sorted row Ids for dogColors result table changed'
|
|
2487
2751
|
* // -> ['cujo', 'fido', 'rex']
|
|
2488
2752
|
*
|
|
2489
2753
|
* store.delListener(listenerId);
|
|
2490
2754
|
* ```
|
|
2491
2755
|
* @example
|
|
2492
2756
|
* This example registers a listener that responds to any change to the sorted
|
|
2493
|
-
*
|
|
2494
|
-
* since the `cellId` parameter is explicitly undefined.
|
|
2757
|
+
* ResultRow Ids of a specific ResultTable. The ResultRow Ids are sorted by
|
|
2758
|
+
* their own value, since the `cellId` parameter is explicitly undefined.
|
|
2495
2759
|
*
|
|
2496
2760
|
* ```js
|
|
2497
2761
|
* const store = createStore().setTable('pets', {
|
|
@@ -2518,14 +2782,14 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2518
2782
|
* 0,
|
|
2519
2783
|
* undefined,
|
|
2520
2784
|
* (queries, tableId, cellId, descending, offset, limit, sortedRowIds) => {
|
|
2521
|
-
* console.log(`Sorted
|
|
2785
|
+
* console.log(`Sorted row Ids for dogColors result table changed`);
|
|
2522
2786
|
* console.log(sortedRowIds);
|
|
2523
2787
|
* // ^ cheaper than calling getSortedRowIds again
|
|
2524
2788
|
* },
|
|
2525
2789
|
* );
|
|
2526
2790
|
*
|
|
2527
2791
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'});
|
|
2528
|
-
* // -> 'Sorted
|
|
2792
|
+
* // -> 'Sorted row Ids for dogColors result table changed'
|
|
2529
2793
|
* // -> ['cujo', 'fido', 'rex']
|
|
2530
2794
|
*
|
|
2531
2795
|
* store.delListener(listenerId);
|
|
@@ -2539,36 +2803,35 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2539
2803
|
descending: boolean,
|
|
2540
2804
|
offset: number,
|
|
2541
2805
|
limit: number | undefined,
|
|
2542
|
-
listener: ResultSortedRowIdsListener
|
|
2806
|
+
listener: ResultSortedRowIdsListener<Schemas>,
|
|
2543
2807
|
): Id;
|
|
2544
2808
|
|
|
2545
2809
|
/**
|
|
2546
2810
|
* The addResultRowListener method registers a listener function with the
|
|
2547
|
-
* Queries object that will be called whenever data in a
|
|
2811
|
+
* Queries object that will be called whenever data in a ResultRow changes.
|
|
2548
2812
|
*
|
|
2549
2813
|
* 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.
|
|
2814
|
+
* with a reference to the Queries object, the Id of the ResultTable that
|
|
2815
|
+
* changed (which is also the query Id), and a GetCellResultChange function in
|
|
2816
|
+
* case you need to inspect any changes that occurred.
|
|
2553
2817
|
*
|
|
2554
|
-
* You can either listen to a single
|
|
2555
|
-
*
|
|
2556
|
-
* (by providing `null` wildcards).
|
|
2818
|
+
* You can either listen to a single ResultRow (by specifying a query Id and
|
|
2819
|
+
* ResultRow Id as the method's first two parameters) or changes to any
|
|
2820
|
+
* ResultRow (by providing `null` wildcards).
|
|
2557
2821
|
*
|
|
2558
2822
|
* 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
|
-
*
|
|
2823
|
+
* wildcarded with `null`. You can listen to a specific ResultRow in a
|
|
2824
|
+
* specific query, any ResultRow in a specific query, a specific ResultRow in
|
|
2825
|
+
* any query, or any ResultRow in any query.
|
|
2562
2826
|
*
|
|
2563
2827
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2564
|
-
* @param rowId The Id of the
|
|
2565
|
-
* wildcard.
|
|
2828
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
2566
2829
|
* @param listener The function that will be called whenever data in the
|
|
2567
|
-
* matching
|
|
2830
|
+
* matching ResultRow changes.
|
|
2568
2831
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2569
2832
|
* @example
|
|
2570
2833
|
* This example registers a listener that responds to any changes to a
|
|
2571
|
-
* specific
|
|
2834
|
+
* specific ResultRow.
|
|
2572
2835
|
*
|
|
2573
2836
|
* ```js
|
|
2574
2837
|
* const store = createStore().setTable('pets', {
|
|
@@ -2603,7 +2866,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2603
2866
|
* ```
|
|
2604
2867
|
* @example
|
|
2605
2868
|
* This example registers a listener that responds to any changes to any
|
|
2606
|
-
*
|
|
2869
|
+
* ResultRow.
|
|
2607
2870
|
*
|
|
2608
2871
|
* ```js
|
|
2609
2872
|
* const store = createStore().setTable('pets', {
|
|
@@ -2643,40 +2906,39 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2643
2906
|
addResultRowListener(
|
|
2644
2907
|
queryId: IdOrNull,
|
|
2645
2908
|
rowId: IdOrNull,
|
|
2646
|
-
listener: ResultRowListener
|
|
2909
|
+
listener: ResultRowListener<Schemas>,
|
|
2647
2910
|
): Id;
|
|
2648
2911
|
|
|
2649
2912
|
/**
|
|
2650
2913
|
* The addResultCellIdsListener method registers a listener function with the
|
|
2651
|
-
* Queries object that will be called whenever the
|
|
2652
|
-
* change.
|
|
2914
|
+
* Queries object that will be called whenever the ResultCell Ids in a
|
|
2915
|
+
* ResultRow change.
|
|
2653
2916
|
*
|
|
2654
2917
|
* 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
|
|
2918
|
+
* called with a reference to the Queries object, the Id of the ResultTable
|
|
2919
|
+
* (which is also the query Id), and the Id of the ResultRow that changed.
|
|
2657
2920
|
*
|
|
2658
|
-
* Such a listener is only called when a
|
|
2659
|
-
* the
|
|
2921
|
+
* Such a listener is only called when a ResultCell is added to, or removed
|
|
2922
|
+
* from, the ResultRow. To listen to all changes in the ResultRow, use the
|
|
2660
2923
|
* addResultRowListener method.
|
|
2661
2924
|
*
|
|
2662
|
-
* You can either listen to a single
|
|
2663
|
-
*
|
|
2664
|
-
* providing `null` wildcards).
|
|
2925
|
+
* You can either listen to a single ResultRow (by specifying the query Id and
|
|
2926
|
+
* ResultRow Id as the method's first two parameters) or changes to any
|
|
2927
|
+
* ResultRow (by providing `null` wildcards).
|
|
2665
2928
|
*
|
|
2666
2929
|
* 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
|
-
*
|
|
2930
|
+
* wildcarded with `null`. You can listen to a specific ResultRow in a
|
|
2931
|
+
* specific query, any ResultRow in a specific query, a specific ResultRow in
|
|
2932
|
+
* any query, or any ResultRow in any query.
|
|
2670
2933
|
*
|
|
2671
2934
|
* @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.
|
|
2935
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
2936
|
+
* @param listener The function that will be called whenever the ResultCell
|
|
2937
|
+
* Ids in the ResultRow change.
|
|
2676
2938
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2677
2939
|
* @example
|
|
2678
|
-
* This example registers a listener that responds to any change to the
|
|
2679
|
-
* Ids of a specific
|
|
2940
|
+
* This example registers a listener that responds to any change to the
|
|
2941
|
+
* ResultCell Ids of a specific ResultRow.
|
|
2680
2942
|
*
|
|
2681
2943
|
* ```js
|
|
2682
2944
|
* const store = createStore().setTable('pets', {
|
|
@@ -2711,8 +2973,8 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2711
2973
|
* store.delListener(listenerId);
|
|
2712
2974
|
* ```
|
|
2713
2975
|
* @example
|
|
2714
|
-
* This example registers a listener that responds to any change to the
|
|
2715
|
-
* Ids of any
|
|
2976
|
+
* This example registers a listener that responds to any change to the
|
|
2977
|
+
* ResultCell Ids of any ResultRow.
|
|
2716
2978
|
*
|
|
2717
2979
|
* ```js
|
|
2718
2980
|
* const store = createStore().setTable('pets', {
|
|
@@ -2756,40 +3018,39 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2756
3018
|
addResultCellIdsListener(
|
|
2757
3019
|
queryId: IdOrNull,
|
|
2758
3020
|
rowId: IdOrNull,
|
|
2759
|
-
listener: ResultCellIdsListener
|
|
3021
|
+
listener: ResultCellIdsListener<Schemas>,
|
|
2760
3022
|
): Id;
|
|
2761
3023
|
|
|
2762
3024
|
/**
|
|
2763
3025
|
* The addResultCellListener method registers a listener function with the
|
|
2764
|
-
* Queries object that will be called whenever data in a
|
|
3026
|
+
* Queries object that will be called whenever data in a ResultCell changes.
|
|
2765
3027
|
*
|
|
2766
3028
|
* 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.
|
|
3029
|
+
* with a reference to the Queries object, the Id of the ResultTable that
|
|
3030
|
+
* changed (which is also the query Id), the Id of the ResultRow that changed,
|
|
3031
|
+
* the Id of the ResultCell that changed, the new ResultCell value, the old
|
|
3032
|
+
* ResultCell value, and a GetCellResultChange function in case you need to
|
|
3033
|
+
* inspect any changes that occurred.
|
|
2772
3034
|
*
|
|
2773
|
-
* You can either listen to a single
|
|
2774
|
-
* Id, and
|
|
2775
|
-
*
|
|
3035
|
+
* You can either listen to a single ResultRow (by specifying a query Id,
|
|
3036
|
+
* ResultRow Id, and ResultCell Id as the method's first three parameters) or
|
|
3037
|
+
* changes to any ResultCell (by providing `null` wildcards).
|
|
2776
3038
|
*
|
|
2777
3039
|
* 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.
|
|
3040
|
+
* be wildcarded with `null`. You can listen to a specific ResultCell in a
|
|
3041
|
+
* specific ResultRow in a specific query, any ResultCell in any ResultRow in
|
|
3042
|
+
* any query, for example - or every other combination of wildcards.
|
|
2781
3043
|
*
|
|
2782
3044
|
* @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
|
|
3045
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
3046
|
+
* @param cellId The Id of the ResultCell to listen to, or `null` as a
|
|
2786
3047
|
* wildcard.
|
|
2787
3048
|
* @param listener The function that will be called whenever data in the
|
|
2788
|
-
* matching
|
|
3049
|
+
* matching ResultCell changes.
|
|
2789
3050
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2790
3051
|
* @example
|
|
2791
3052
|
* This example registers a listener that responds to any changes to a
|
|
2792
|
-
* specific
|
|
3053
|
+
* specific ResultCell.
|
|
2793
3054
|
*
|
|
2794
3055
|
* ```js
|
|
2795
3056
|
* const store = createStore().setTable('pets', {
|
|
@@ -2829,7 +3090,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2829
3090
|
* ```
|
|
2830
3091
|
* @example
|
|
2831
3092
|
* This example registers a listener that responds to any changes to any
|
|
2832
|
-
*
|
|
3093
|
+
* ResultCell.
|
|
2833
3094
|
*
|
|
2834
3095
|
* ```js
|
|
2835
3096
|
* const store = createStore().setTable('pets', {
|
|
@@ -2874,7 +3135,7 @@ export interface Queries<Schemas extends OptionalSchemas = NoSchemas> {
|
|
|
2874
3135
|
queryId: IdOrNull,
|
|
2875
3136
|
rowId: IdOrNull,
|
|
2876
3137
|
cellId: IdOrNull,
|
|
2877
|
-
listener: ResultCellListener
|
|
3138
|
+
listener: ResultCellListener<Schemas>,
|
|
2878
3139
|
): Id;
|
|
2879
3140
|
|
|
2880
3141
|
/**
|