tinybase 3.1.0-beta.3 → 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/bin/cli.js +1 -1
- package/lib/cjs/tools.cjs +1 -1
- package/lib/cjs/tools.cjs.gz +0 -0
- package/lib/cjs-es6/tools.cjs +1 -1
- package/lib/cjs-es6/tools.cjs.gz +0 -0
- package/lib/debug/tools.js +14 -621
- package/lib/debug/ui-react.js +2 -2
- package/lib/es6/tools.js +1 -1
- package/lib/es6/tools.js.gz +0 -0
- package/lib/tools.js +1 -1
- package/lib/tools.js.gz +0 -0
- package/lib/{debug → types}/indexes.d.ts +1 -1
- package/lib/{debug → types}/metrics.d.ts +40 -41
- package/lib/{cjs-es6 → types}/queries.d.ts +466 -299
- package/lib/{debug → types}/relationships.d.ts +2 -2
- package/lib/{debug → types}/store.d.ts +115 -124
- package/lib/types/tinybase.d.ts +14 -0
- package/lib/{debug → types}/tools.d.ts +3 -174
- package/lib/{cjs-es6 → types}/ui-react.d.ts +11 -5
- package/lib/{cjs-es6 → types/with-schemas}/checkpoints.d.ts +20 -16
- package/lib/{cjs → types/with-schemas}/indexes.d.ts +44 -23
- 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 +61 -55
- package/lib/{debug → types/with-schemas}/persisters.d.ts +31 -25
- package/lib/{debug → types/with-schemas}/queries.d.ts +615 -350
- package/lib/{cjs → types/with-schemas}/relationships.d.ts +42 -25
- package/lib/{cjs-es6 → types/with-schemas}/store.d.ts +758 -302
- package/lib/types/with-schemas/tinybase.d.ts +14 -0
- package/lib/{cjs-es6 → types/with-schemas}/tools.d.ts +11 -180
- package/lib/{cjs → types/with-schemas}/ui-react.d.ts +817 -1314
- package/lib/umd/tools.js +1 -1
- package/lib/umd/tools.js.gz +0 -0
- package/lib/umd-es6/tools.js +1 -1
- package/lib/umd-es6/tools.js.gz +0 -0
- package/package.json +149 -33
- package/readme.md +3 -3
- package/lib/cjs/checkpoints.d.ts +0 -959
- package/lib/cjs/persisters.d.ts +0 -727
- package/lib/cjs/queries.d.ts +0 -3024
- package/lib/cjs/store.d.ts +0 -5244
- package/lib/cjs/tinybase.d.ts +0 -14
- package/lib/cjs/tools.d.ts +0 -702
- package/lib/cjs-es6/indexes.d.ts +0 -966
- package/lib/cjs-es6/metrics.d.ts +0 -827
- package/lib/cjs-es6/relationships.d.ts +0 -1201
- package/lib/cjs-es6/tinybase.d.ts +0 -14
- package/lib/common.d.ts +0 -115
- package/lib/debug/checkpoints.d.ts +0 -959
- package/lib/debug/common.d.ts +0 -115
- package/lib/debug/tinybase.d.ts +0 -14
- package/lib/debug/ui-react.d.ts +0 -10921
- package/lib/es6/checkpoints.d.ts +0 -959
- package/lib/es6/common.d.ts +0 -115
- package/lib/es6/indexes.d.ts +0 -966
- package/lib/es6/metrics.d.ts +0 -827
- package/lib/es6/persisters.d.ts +0 -727
- package/lib/es6/queries.d.ts +0 -3024
- package/lib/es6/relationships.d.ts +0 -1201
- package/lib/es6/store.d.ts +0 -5244
- package/lib/es6/tinybase.d.ts +0 -14
- package/lib/es6/tools.d.ts +0 -702
- package/lib/es6/ui-react.d.ts +0 -10921
- package/lib/indexes.d.ts +0 -966
- package/lib/metrics.d.ts +0 -827
- package/lib/persisters.d.ts +0 -727
- package/lib/queries.d.ts +0 -3024
- package/lib/relationships.d.ts +0 -1201
- package/lib/store.d.ts +0 -5244
- package/lib/tinybase.d.ts +0 -14
- package/lib/tools.d.ts +0 -702
- package/lib/ui-react.d.ts +0 -10921
- package/lib/umd/checkpoints.d.ts +0 -959
- package/lib/umd/common.d.ts +0 -115
- package/lib/umd/indexes.d.ts +0 -966
- package/lib/umd/metrics.d.ts +0 -827
- package/lib/umd/persisters.d.ts +0 -727
- package/lib/umd/queries.d.ts +0 -3024
- package/lib/umd/relationships.d.ts +0 -1201
- package/lib/umd/store.d.ts +0 -5244
- package/lib/umd/tinybase.d.ts +0 -14
- package/lib/umd/tools.d.ts +0 -702
- package/lib/umd/ui-react.d.ts +0 -10921
- package/lib/umd-es6/checkpoints.d.ts +0 -959
- package/lib/umd-es6/common.d.ts +0 -115
- package/lib/umd-es6/indexes.d.ts +0 -966
- package/lib/umd-es6/metrics.d.ts +0 -827
- package/lib/umd-es6/persisters.d.ts +0 -727
- package/lib/umd-es6/queries.d.ts +0 -3024
- package/lib/umd-es6/relationships.d.ts +0 -1201
- package/lib/umd-es6/store.d.ts +0 -5244
- package/lib/umd-es6/tinybase.d.ts +0 -14
- package/lib/umd-es6/tools.d.ts +0 -702
- package/lib/umd-es6/ui-react.d.ts +0 -10921
- /package/lib/{checkpoints.d.ts → types/checkpoints.d.ts} +0 -0
- /package/lib/{cjs-es6 → types}/common.d.ts +0 -0
- /package/lib/{cjs-es6 → types}/persisters.d.ts +0 -0
- /package/lib/{cjs → types/with-schemas}/common.d.ts +0 -0
|
@@ -14,18 +14,79 @@
|
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
Cell,
|
|
17
|
-
CellCallback,
|
|
18
17
|
CellOrUndefined,
|
|
19
18
|
GetCell,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
NoTablesSchema,
|
|
20
|
+
OptionalSchemas,
|
|
21
|
+
OptionalTablesSchema,
|
|
23
22
|
Store,
|
|
24
|
-
Table,
|
|
25
|
-
TableCallback,
|
|
26
23
|
} from './store.d';
|
|
24
|
+
import {CellIdFromSchema, TableIdFromSchema} from './internal/store';
|
|
25
|
+
import {GetResultCell, JoinedCellIdOrId} from './internal/queries';
|
|
27
26
|
import {Id, IdOrNull, Ids} from './common.d';
|
|
28
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
|
+
|
|
29
90
|
/**
|
|
30
91
|
* The Aggregate type describes a custom function that takes an array of Cell
|
|
31
92
|
* values and returns an aggregate of them.
|
|
@@ -40,7 +101,7 @@ import {Id, IdOrNull, Ids} from './common.d';
|
|
|
40
101
|
* @category Aggregators
|
|
41
102
|
* @since v2.0.0
|
|
42
103
|
*/
|
|
43
|
-
export type Aggregate = (cells:
|
|
104
|
+
export type Aggregate = (cells: ResultCell[], length: number) => ResultCell;
|
|
44
105
|
|
|
45
106
|
/**
|
|
46
107
|
* The AggregateAdd type describes a function that can be used to optimize a
|
|
@@ -67,10 +128,10 @@ export type Aggregate = (cells: Cell[], length: number) => Cell;
|
|
|
67
128
|
* @since v2.0.0
|
|
68
129
|
*/
|
|
69
130
|
export type AggregateAdd = (
|
|
70
|
-
current:
|
|
71
|
-
add:
|
|
131
|
+
current: ResultCell,
|
|
132
|
+
add: ResultCell,
|
|
72
133
|
length: number,
|
|
73
|
-
) =>
|
|
134
|
+
) => ResultCellOrUndefined;
|
|
74
135
|
|
|
75
136
|
/**
|
|
76
137
|
* The AggregateRemove type describes a function that can be used to optimize a
|
|
@@ -100,10 +161,10 @@ export type AggregateAdd = (
|
|
|
100
161
|
* @since v2.0.0
|
|
101
162
|
*/
|
|
102
163
|
export type AggregateRemove = (
|
|
103
|
-
current:
|
|
104
|
-
remove:
|
|
164
|
+
current: ResultCell,
|
|
165
|
+
remove: ResultCell,
|
|
105
166
|
length: number,
|
|
106
|
-
) =>
|
|
167
|
+
) => ResultCellOrUndefined;
|
|
107
168
|
|
|
108
169
|
/**
|
|
109
170
|
* The AggregateReplace type describes a function that can be used to optimize a
|
|
@@ -132,11 +193,11 @@ export type AggregateRemove = (
|
|
|
132
193
|
* @since v2.0.0
|
|
133
194
|
*/
|
|
134
195
|
export type AggregateReplace = (
|
|
135
|
-
current:
|
|
136
|
-
add:
|
|
137
|
-
remove:
|
|
196
|
+
current: ResultCell,
|
|
197
|
+
add: ResultCell,
|
|
198
|
+
remove: ResultCell,
|
|
138
199
|
length: number,
|
|
139
|
-
) =>
|
|
200
|
+
) => ResultCellOrUndefined;
|
|
140
201
|
|
|
141
202
|
/**
|
|
142
203
|
* The QueryCallback type describes a function that takes a query's Id.
|
|
@@ -151,76 +212,133 @@ export type AggregateReplace = (
|
|
|
151
212
|
*/
|
|
152
213
|
export type QueryCallback = (queryId: Id) => void;
|
|
153
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
|
+
|
|
154
265
|
/**
|
|
155
266
|
* The ResultTableListener type describes a function that is used to listen to
|
|
156
|
-
* changes to a query's
|
|
267
|
+
* changes to a query's ResultTable.
|
|
157
268
|
*
|
|
158
269
|
* A ResultTableListener is provided when using the addResultTableListener
|
|
159
270
|
* method. See that method for specific examples.
|
|
160
271
|
*
|
|
161
272
|
* When called, a ResultTableListener is given a reference to the Queries
|
|
162
|
-
* object, the Id of the
|
|
163
|
-
* and a
|
|
164
|
-
* 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.
|
|
165
276
|
*
|
|
166
277
|
* @param queries A reference to the Queries object that changed.
|
|
167
|
-
* @param tableId The Id of the
|
|
168
|
-
*
|
|
169
|
-
*
|
|
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.
|
|
170
282
|
* @category Listener
|
|
171
283
|
* @since v2.0.0
|
|
172
284
|
*/
|
|
173
|
-
export type ResultTableListener = (
|
|
174
|
-
queries: Queries
|
|
285
|
+
export type ResultTableListener<Schemas extends OptionalSchemas> = (
|
|
286
|
+
queries: Queries<Schemas>,
|
|
175
287
|
tableId: Id,
|
|
176
|
-
getCellChange:
|
|
288
|
+
getCellChange: GetCellResultChange,
|
|
177
289
|
) => void;
|
|
178
290
|
|
|
179
291
|
/**
|
|
180
292
|
* The ResultRowIdsListener type describes a function that is used to listen to
|
|
181
|
-
* changes to the
|
|
293
|
+
* changes to the ResultRow Ids in a query's ResultTable.
|
|
182
294
|
*
|
|
183
295
|
* A ResultRowIdsListener is provided when using the addResultRowIdsListener
|
|
184
296
|
* method. See that method for specific examples.
|
|
185
297
|
*
|
|
186
298
|
* When called, a ResultRowIdsListener is given a reference to the Queries
|
|
187
|
-
* object, and the Id of the
|
|
188
|
-
* the query Id).
|
|
299
|
+
* object, and the Id of the ResultTable whose ResultRow Ids changed (which is
|
|
300
|
+
* the same as the query Id).
|
|
189
301
|
*
|
|
190
302
|
* @param queries A reference to the Queries object that changed.
|
|
191
|
-
* @param tableId The Id of the
|
|
303
|
+
* @param tableId The Id of the ResultTable that changed, which is also the
|
|
304
|
+
* query Id.
|
|
192
305
|
* @category Listener
|
|
193
306
|
* @since v2.0.0
|
|
194
307
|
*/
|
|
195
|
-
export type ResultRowIdsListener = (
|
|
308
|
+
export type ResultRowIdsListener<Schemas extends OptionalSchemas> = (
|
|
309
|
+
queries: Queries<Schemas>,
|
|
310
|
+
tableId: Id,
|
|
311
|
+
) => void;
|
|
196
312
|
|
|
197
313
|
/**
|
|
198
314
|
* The ResultSortedRowIdsListener type describes a function that is used to
|
|
199
|
-
* listen to changes to the sorted
|
|
315
|
+
* listen to changes to the sorted ResultRow Ids in a query's ResultTable.
|
|
200
316
|
*
|
|
201
317
|
* A ResultSortedRowIdsListener is provided when using the
|
|
202
318
|
* addResultSortedRowIdsListener method. See that method for specific examples.
|
|
203
319
|
*
|
|
204
320
|
* When called, a ResultSortedRowIdsListener is given a reference to the Queries
|
|
205
|
-
* object, the Id of the
|
|
206
|
-
* query Id), the
|
|
207
|
-
* and the offset and limit of the number of Ids returned,
|
|
208
|
-
* purposes. It also receives the sorted array of Ids itself, so
|
|
209
|
-
* use them in the listener without the additional cost of an
|
|
210
|
-
* 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.
|
|
211
327
|
*
|
|
212
328
|
* @param queries A reference to the Queries object that changed.
|
|
213
|
-
* @param tableId The Id of the
|
|
214
|
-
*
|
|
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.
|
|
215
333
|
* @param descending Whether the sorting was in descending order.
|
|
216
|
-
* @param offset The number of
|
|
217
|
-
* @param limit The maximum number of
|
|
218
|
-
* @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.
|
|
219
337
|
* @category Listener
|
|
220
338
|
* @since v2.0.0
|
|
221
339
|
*/
|
|
222
|
-
export type ResultSortedRowIdsListener = (
|
|
223
|
-
queries: Queries
|
|
340
|
+
export type ResultSortedRowIdsListener<Schemas extends OptionalSchemas> = (
|
|
341
|
+
queries: Queries<Schemas>,
|
|
224
342
|
tableId: Id,
|
|
225
343
|
cellId: Id | undefined,
|
|
226
344
|
descending: boolean,
|
|
@@ -231,88 +349,131 @@ export type ResultSortedRowIdsListener = (
|
|
|
231
349
|
|
|
232
350
|
/**
|
|
233
351
|
* The ResultRowListener type describes a function that is used to listen to
|
|
234
|
-
* changes to a
|
|
352
|
+
* changes to a ResultRow in a query's ResultTable.
|
|
235
353
|
*
|
|
236
354
|
* A ResultRowListener is provided when using the addResultRowListener method.
|
|
237
355
|
* See that method for specific examples.
|
|
238
356
|
*
|
|
239
357
|
* When called, a ResultRowListener is given a reference to the Queries object,
|
|
240
|
-
* the Id of the
|
|
241
|
-
* of the
|
|
242
|
-
* 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.
|
|
243
361
|
*
|
|
244
362
|
* @param queries A reference to the Queries object that changed.
|
|
245
|
-
* @param tableId The Id of the
|
|
246
|
-
*
|
|
247
|
-
* @param
|
|
248
|
-
*
|
|
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.
|
|
249
368
|
* @category Listener
|
|
250
369
|
* @since v2.0.0
|
|
251
370
|
*/
|
|
252
|
-
export type ResultRowListener = (
|
|
253
|
-
queries: Queries
|
|
371
|
+
export type ResultRowListener<Schemas extends OptionalSchemas> = (
|
|
372
|
+
queries: Queries<Schemas>,
|
|
254
373
|
tableId: Id,
|
|
255
374
|
rowId: Id,
|
|
256
|
-
getCellChange:
|
|
375
|
+
getCellChange: GetCellResultChange,
|
|
257
376
|
) => void;
|
|
258
377
|
|
|
259
378
|
/**
|
|
260
379
|
* The ResultCellIdsListener type describes a function that is used to listen to
|
|
261
|
-
* changes to the
|
|
380
|
+
* changes to the ResultCell Ids in a ResultRow in a query's ResultTable.
|
|
262
381
|
*
|
|
263
382
|
* A ResultCellIdsListener is provided when using the addResultCellIdsListener
|
|
264
383
|
* method. See that method for specific examples.
|
|
265
384
|
*
|
|
266
385
|
* When called, a ResultCellIdsListener is given a reference to the Queries
|
|
267
|
-
* object, the Id of the
|
|
268
|
-
* 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.
|
|
269
388
|
*
|
|
270
389
|
* @param queries A reference to the Queries object that changed.
|
|
271
|
-
* @param tableId The Id of the
|
|
272
|
-
*
|
|
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.
|
|
273
393
|
* @category Listener
|
|
274
394
|
* @since v2.0.0
|
|
275
395
|
*/
|
|
276
|
-
export type ResultCellIdsListener = (
|
|
277
|
-
queries: Queries
|
|
396
|
+
export type ResultCellIdsListener<Schemas extends OptionalSchemas> = (
|
|
397
|
+
queries: Queries<Schemas>,
|
|
278
398
|
tableId: Id,
|
|
279
399
|
rowId: Id,
|
|
280
400
|
) => void;
|
|
281
401
|
|
|
282
402
|
/**
|
|
283
403
|
* The ResultCellListener type describes a function that is used to listen to
|
|
284
|
-
* changes to a
|
|
404
|
+
* changes to a ResultCell in a query's ResultTable.
|
|
285
405
|
*
|
|
286
406
|
* A ResultCellListener is provided when using the addResultCellListener method.
|
|
287
407
|
* See that method for specific examples.
|
|
288
408
|
*
|
|
289
409
|
* When called, a ResultCellListener is given a reference to the Queries object,
|
|
290
|
-
* the Id of the
|
|
291
|
-
* of the
|
|
292
|
-
* the new value of the
|
|
293
|
-
* 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.
|
|
294
415
|
*
|
|
295
416
|
* @param queries A reference to the Queries object that changed.
|
|
296
|
-
* @param tableId The Id of the
|
|
297
|
-
*
|
|
298
|
-
* @param
|
|
299
|
-
* @param
|
|
300
|
-
* @param
|
|
301
|
-
* @param
|
|
302
|
-
*
|
|
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.
|
|
303
425
|
* @category Listener
|
|
304
426
|
* @since v2.0.0
|
|
305
427
|
*/
|
|
306
|
-
export type ResultCellListener = (
|
|
307
|
-
queries: Queries
|
|
428
|
+
export type ResultCellListener<Schemas extends OptionalSchemas> = (
|
|
429
|
+
queries: Queries<Schemas>,
|
|
308
430
|
tableId: Id,
|
|
309
431
|
rowId: Id,
|
|
310
432
|
cellId: Id,
|
|
311
|
-
newCell:
|
|
312
|
-
oldCell:
|
|
313
|
-
getCellChange:
|
|
433
|
+
newCell: ResultCell,
|
|
434
|
+
oldCell: ResultCell,
|
|
435
|
+
getCellChange: GetCellResultChange,
|
|
314
436
|
) => void;
|
|
315
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
|
+
|
|
316
477
|
/**
|
|
317
478
|
* The QueriesListenerStats type describes the number of listeners registered
|
|
318
479
|
* with the Queries object, and can be used for debugging purposes.
|
|
@@ -357,20 +518,25 @@ export type QueriesListenerStats = {
|
|
|
357
518
|
* @category Callback
|
|
358
519
|
* @since v2.0.0
|
|
359
520
|
*/
|
|
360
|
-
export type GetTableCell
|
|
521
|
+
export type GetTableCell<
|
|
522
|
+
Schema extends OptionalTablesSchema,
|
|
523
|
+
RootTableId extends TableIdFromSchema<Schema>,
|
|
524
|
+
> = {
|
|
361
525
|
/**
|
|
362
|
-
* When called with one parameter, this function will return the value of
|
|
363
|
-
* specified Cell from the query's
|
|
364
|
-
* 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.
|
|
365
529
|
*
|
|
366
530
|
* @param cellId The Id of the Cell to fetch the value for.
|
|
367
531
|
* @returns A Cell value or `undefined`.
|
|
368
532
|
*/
|
|
369
|
-
|
|
533
|
+
<RootCellId extends CellIdFromSchema<Schema, RootTableId>>(
|
|
534
|
+
cellId: RootCellId,
|
|
535
|
+
): CellOrUndefined<Schema, RootTableId, RootCellId>;
|
|
370
536
|
/**
|
|
371
|
-
* When called with two parameters, this function will return the value of
|
|
372
|
-
* specified Cell from a Table that has been joined in the query, for
|
|
373
|
-
* 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.
|
|
374
540
|
*
|
|
375
541
|
* @param joinedTableId The Id of the Table to fetch the value from. If the
|
|
376
542
|
* underlying Table was joined 'as' a different Id, that should instead be
|
|
@@ -378,7 +544,20 @@ export type GetTableCell = {
|
|
|
378
544
|
* @param joinedCellId The Id of the Cell to fetch the value for.
|
|
379
545
|
* @returns A Cell value or `undefined`.
|
|
380
546
|
*/
|
|
381
|
-
|
|
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;
|
|
382
561
|
};
|
|
383
562
|
|
|
384
563
|
/**
|
|
@@ -478,16 +657,21 @@ export type GetTableCell = {
|
|
|
478
657
|
* @category Definition
|
|
479
658
|
* @since v2.0.0
|
|
480
659
|
*/
|
|
481
|
-
export type Select
|
|
660
|
+
export type Select<
|
|
661
|
+
Schema extends OptionalTablesSchema,
|
|
662
|
+
RootTableId extends TableIdFromSchema<Schema>,
|
|
663
|
+
> = {
|
|
482
664
|
/**
|
|
483
665
|
* Calling this function with one Id parameter will indicate that the query
|
|
484
|
-
* 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.
|
|
485
667
|
*
|
|
486
668
|
* @param cellId The Id of the Cell to fetch the value for.
|
|
487
669
|
* @returns A SelectedAs object so that the selected Cell Id can be optionally
|
|
488
670
|
* aliased.
|
|
489
671
|
*/
|
|
490
|
-
|
|
672
|
+
<RootCellId extends CellIdFromSchema<Schema, RootTableId>>(
|
|
673
|
+
cellId: RootCellId,
|
|
674
|
+
): SelectedAs;
|
|
491
675
|
/**
|
|
492
676
|
* Calling this function with two parameters will indicate that the query
|
|
493
677
|
* should select the value of the specified Cell from a Table that has been
|
|
@@ -500,11 +684,14 @@ export type Select = {
|
|
|
500
684
|
* @returns A SelectedAs object so that the selected Cell Id can be optionally
|
|
501
685
|
* aliased.
|
|
502
686
|
*/
|
|
503
|
-
|
|
687
|
+
<JoinedTableId extends TableIdFromSchema<Schema> | Id>(
|
|
688
|
+
joinedTableId: JoinedTableId,
|
|
689
|
+
joinedCellId: JoinedCellIdOrId<Schema, JoinedTableId>,
|
|
690
|
+
): SelectedAs;
|
|
504
691
|
/**
|
|
505
692
|
* Calling this function with one callback parameter will indicate that the
|
|
506
693
|
* query should select a calculated value, based on one or more Cell values in
|
|
507
|
-
* the
|
|
694
|
+
* the root Table or a joined Table, or on the root Table's Row Id.
|
|
508
695
|
*
|
|
509
696
|
* @param getCell A callback that takes a GetTableCell function and the main
|
|
510
697
|
* Table's Row Id. These can be used to programmatically create a calculated
|
|
@@ -513,9 +700,13 @@ export type Select = {
|
|
|
513
700
|
* aliased.
|
|
514
701
|
*/
|
|
515
702
|
(
|
|
516
|
-
getCell: (
|
|
703
|
+
getCell: (
|
|
704
|
+
getTableCell: GetTableCell<Schema, RootTableId>,
|
|
705
|
+
rowId: Id,
|
|
706
|
+
) => ResultCellOrUndefined,
|
|
517
707
|
): SelectedAs;
|
|
518
708
|
};
|
|
709
|
+
|
|
519
710
|
/**
|
|
520
711
|
* The SelectedAs type describes an object returned from calling a Select
|
|
521
712
|
* function so that the selected Cell Id can be optionally aliased.
|
|
@@ -586,11 +777,11 @@ export type SelectedAs = {
|
|
|
586
777
|
* distant join Table.
|
|
587
778
|
*
|
|
588
779
|
* Because a Join clause is used to identify which unique Row Id of the joined
|
|
589
|
-
* 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
|
|
590
781
|
* join' semantics you may be familiar with from SQL. This means that an
|
|
591
782
|
* unfiltered query will only ever return the same number of Rows as the main
|
|
592
783
|
* Table being queried, and indeed the resulting table (assuming it has not been
|
|
593
|
-
* aggregated) will even preserve the
|
|
784
|
+
* aggregated) will even preserve the root Table's original Row Ids.
|
|
594
785
|
*
|
|
595
786
|
* @example
|
|
596
787
|
* This example shows a query that joins a single Table by using an Id present
|
|
@@ -628,7 +819,7 @@ export type SelectedAs = {
|
|
|
628
819
|
* This example shows a query that joins the same underlying Table twice, and
|
|
629
820
|
* aliases them (and the selected Cell Ids). Note the left-join semantics: Felix
|
|
630
821
|
* the cat was bought, but the seller was unknown. The record still exists in
|
|
631
|
-
* the
|
|
822
|
+
* the ResultTable.
|
|
632
823
|
*
|
|
633
824
|
* ```js
|
|
634
825
|
* const store = createStore()
|
|
@@ -661,7 +852,7 @@ export type SelectedAs = {
|
|
|
661
852
|
* ```
|
|
662
853
|
* @example
|
|
663
854
|
* This example shows a query that calculates the Id of the joined Table based
|
|
664
|
-
* from multiple values in the
|
|
855
|
+
* from multiple values in the root Table rather than a single Cell.
|
|
665
856
|
*
|
|
666
857
|
* ```js
|
|
667
858
|
* const store = createStore()
|
|
@@ -736,34 +927,40 @@ export type SelectedAs = {
|
|
|
736
927
|
* @category Definition
|
|
737
928
|
* @since v2.0.0
|
|
738
929
|
*/
|
|
739
|
-
export type Join
|
|
930
|
+
export type Join<
|
|
931
|
+
Schema extends OptionalTablesSchema,
|
|
932
|
+
RootTableId extends TableIdFromSchema<Schema>,
|
|
933
|
+
> = {
|
|
740
934
|
/**
|
|
741
935
|
* Calling this function with two Id parameters will indicate that the join to
|
|
742
936
|
* a Row in an adjacent Table is made by finding its Id in a Cell of the
|
|
743
|
-
* query's
|
|
937
|
+
* query's root Table.
|
|
744
938
|
*
|
|
745
939
|
* @param joinedTableId The Id of the Table to join to.
|
|
746
|
-
* @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
|
|
747
941
|
* Table's Row Id.
|
|
748
942
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
749
943
|
* aliased.
|
|
750
944
|
*/
|
|
751
|
-
(
|
|
945
|
+
(
|
|
946
|
+
joinedTableId: TableIdFromSchema<Schema>,
|
|
947
|
+
on: CellIdFromSchema<Schema, RootTableId>,
|
|
948
|
+
): JoinedAs;
|
|
752
949
|
/**
|
|
753
950
|
* Calling this function with two parameters (where the second is a function)
|
|
754
951
|
* will indicate that the join to a Row in an adjacent Table is made by
|
|
755
|
-
* 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.
|
|
756
953
|
*
|
|
757
954
|
* @param joinedTableId The Id of the Table to join to.
|
|
758
|
-
* @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
|
|
759
956
|
* Id. These can be used to programmatically calculate the joined Table's Row
|
|
760
957
|
* Id.
|
|
761
958
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
762
959
|
* aliased.
|
|
763
960
|
*/
|
|
764
961
|
(
|
|
765
|
-
joinedTableId:
|
|
766
|
-
on: (getCell: GetCell, rowId: Id) => Id | undefined,
|
|
962
|
+
joinedTableId: TableIdFromSchema<Schema>,
|
|
963
|
+
on: (getCell: GetCell<Schema, RootTableId>, rowId: Id) => Id | undefined,
|
|
767
964
|
): JoinedAs;
|
|
768
965
|
/**
|
|
769
966
|
* Calling this function with three Id parameters will indicate that the join
|
|
@@ -779,7 +976,19 @@ export type Join = {
|
|
|
779
976
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
780
977
|
* aliased.
|
|
781
978
|
*/
|
|
782
|
-
|
|
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;
|
|
783
992
|
/**
|
|
784
993
|
* Calling this function with three parameters (where the third is a function)
|
|
785
994
|
* will indicate that the join to a Row in distant Table is made by
|
|
@@ -796,15 +1005,24 @@ export type Join = {
|
|
|
796
1005
|
* @returns A JoinedAs object so that the joined Table Id can be optionally
|
|
797
1006
|
* aliased.
|
|
798
1007
|
*/
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
1008
|
+
<
|
|
1009
|
+
IntermediateJoinedTableId extends TableIdFromSchema<Schema> | Id =
|
|
1010
|
+
| TableIdFromSchema<Schema>
|
|
1011
|
+
| Id,
|
|
1012
|
+
>(
|
|
1013
|
+
joinedTableId: TableIdFromSchema<Schema>,
|
|
1014
|
+
fromIntermediateJoinedTableId: IntermediateJoinedTableId,
|
|
802
1015
|
on: (
|
|
803
|
-
|
|
804
|
-
|
|
1016
|
+
// prettier-ignore
|
|
1017
|
+
getIntermediateJoinedCell:
|
|
1018
|
+
IntermediateJoinedTableId extends TableIdFromSchema<Schema>
|
|
1019
|
+
? GetCell<Schema, IntermediateJoinedTableId>
|
|
1020
|
+
: GetCell<NoTablesSchema, Id>,
|
|
1021
|
+
intermediateJoinedRowId: Id,
|
|
805
1022
|
) => Id | undefined,
|
|
806
1023
|
): JoinedAs;
|
|
807
1024
|
};
|
|
1025
|
+
|
|
808
1026
|
/**
|
|
809
1027
|
* The JoinedAs type describes an object returned from calling a Join function
|
|
810
1028
|
* so that the joined Table Id can be optionally aliased.
|
|
@@ -813,6 +1031,9 @@ export type Join = {
|
|
|
813
1031
|
* create two joins to the same underlying Table, both _without_ aliases), only
|
|
814
1032
|
* the latter of two will be used in the query.
|
|
815
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
|
+
*
|
|
816
1037
|
* @example
|
|
817
1038
|
* This example shows a query that joins the same underlying Table twice, for
|
|
818
1039
|
* different purposes. Both joins are aliased with the 'as' function to
|
|
@@ -850,17 +1071,22 @@ export type Join = {
|
|
|
850
1071
|
* @category Definition
|
|
851
1072
|
* @since v2.0.0
|
|
852
1073
|
*/
|
|
853
|
-
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
|
+
};
|
|
854
1080
|
|
|
855
1081
|
/**
|
|
856
1082
|
* The Where type describes a function that lets you specify conditions to
|
|
857
|
-
* filter results, based on the underlying Cells of the
|
|
1083
|
+
* filter results, based on the underlying Cells of the root or joined Tables.
|
|
858
1084
|
*
|
|
859
1085
|
* The Where function is provided to the third `query` parameter of the
|
|
860
1086
|
* setQueryDefinition method.
|
|
861
1087
|
*
|
|
862
1088
|
* If you do not specify a Where clause, you should expect every non-empty Row
|
|
863
|
-
* of the
|
|
1089
|
+
* of the root Table to appear in the query's results.
|
|
864
1090
|
*
|
|
865
1091
|
* A Where condition has to be true for a Row to be included in the results.
|
|
866
1092
|
* Each Where class is additive, as though combined with a logical 'and'. If you
|
|
@@ -968,17 +1194,23 @@ export type JoinedAs = {as: (joinedTableId: Id) => void};
|
|
|
968
1194
|
* @category Definition
|
|
969
1195
|
* @since v2.0.0
|
|
970
1196
|
*/
|
|
971
|
-
export type Where
|
|
1197
|
+
export type Where<
|
|
1198
|
+
Schema extends OptionalTablesSchema,
|
|
1199
|
+
RootTableId extends TableIdFromSchema<Schema>,
|
|
1200
|
+
> = {
|
|
972
1201
|
/**
|
|
973
1202
|
* Calling this function with two parameters is used to include only those
|
|
974
|
-
* 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
|
|
975
1204
|
* value.
|
|
976
1205
|
*
|
|
977
|
-
* @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.
|
|
978
1207
|
* @param equals The value that the Cell has to have for the Row to be
|
|
979
1208
|
* included in the result.
|
|
980
1209
|
*/
|
|
981
|
-
|
|
1210
|
+
<RootCellId extends CellIdFromSchema<Schema, RootTableId>>(
|
|
1211
|
+
cellId: RootCellId,
|
|
1212
|
+
equals: Cell<Schema, RootTableId, RootCellId>,
|
|
1213
|
+
): void;
|
|
982
1214
|
/**
|
|
983
1215
|
* Calling this function with three parameters is used to include only those
|
|
984
1216
|
* Rows for which a specified Cell in a joined Table has a specified value.
|
|
@@ -990,7 +1222,22 @@ export type Where = {
|
|
|
990
1222
|
* @param equals The value that the Cell has to have for the Row to be
|
|
991
1223
|
* included in the result.
|
|
992
1224
|
*/
|
|
993
|
-
|
|
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;
|
|
994
1241
|
/**
|
|
995
1242
|
* Calling this function with one callback parameter is used to include only
|
|
996
1243
|
* those Rows which meet a calculated boolean condition, based on values in
|
|
@@ -999,12 +1246,14 @@ export type Where = {
|
|
|
999
1246
|
* @param condition A callback that takes a GetTableCell function and that
|
|
1000
1247
|
* should return `true` for the Row to be included in the result.
|
|
1001
1248
|
*/
|
|
1002
|
-
(
|
|
1249
|
+
(
|
|
1250
|
+
condition: (getTableCell: GetTableCell<Schema, RootTableId>) => boolean,
|
|
1251
|
+
): void;
|
|
1003
1252
|
};
|
|
1004
1253
|
|
|
1005
1254
|
/**
|
|
1006
1255
|
* The Group type describes a function that lets you specify that the values of
|
|
1007
|
-
* a Cell in multiple
|
|
1256
|
+
* a Cell in multiple ResultRows should be aggregated together.
|
|
1008
1257
|
*
|
|
1009
1258
|
* The Group function is provided to the third `query` parameter of the
|
|
1010
1259
|
* setQueryDefinition method. When called, it should refer to a Cell Id (or
|
|
@@ -1044,7 +1293,7 @@ export type Where = {
|
|
|
1044
1293
|
* input values - for example, when a Row is added to the Table.
|
|
1045
1294
|
* @param aggregateRemove A function that can be used to optimize a custom
|
|
1046
1295
|
* Aggregate by providing a shortcut for when a single value is removed from the
|
|
1047
|
-
* input values - for example
|
|
1296
|
+
* input values - for example, when a Row is removed from the Table.
|
|
1048
1297
|
* @param aggregateReplace A function that can be used to optimize a custom
|
|
1049
1298
|
* Aggregate by providing a shortcut for when a single value in the input values
|
|
1050
1299
|
* is replaced with another - for example, when a Row is updated.
|
|
@@ -1181,6 +1430,7 @@ export type Group = (
|
|
|
1181
1430
|
aggregateRemove?: AggregateRemove,
|
|
1182
1431
|
aggregateReplace?: AggregateReplace,
|
|
1183
1432
|
) => GroupedAs;
|
|
1433
|
+
|
|
1184
1434
|
/**
|
|
1185
1435
|
* The GroupedAs type describes an object returned from calling a Group function
|
|
1186
1436
|
* so that the grouped Cell Id can be optionally aliased.
|
|
@@ -1219,7 +1469,12 @@ export type Group = (
|
|
|
1219
1469
|
* @category Definition
|
|
1220
1470
|
* @since v2.0.0
|
|
1221
1471
|
*/
|
|
1222
|
-
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
|
+
};
|
|
1223
1478
|
|
|
1224
1479
|
/**
|
|
1225
1480
|
* The Having type describes a function that lets you specify conditions to
|
|
@@ -1312,14 +1567,14 @@ export type GroupedAs = {as: (groupedCellId: Id) => void};
|
|
|
1312
1567
|
export type Having = {
|
|
1313
1568
|
/**
|
|
1314
1569
|
* Calling this function with two parameters is used to include only those
|
|
1315
|
-
* 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
|
|
1316
1571
|
* value.
|
|
1317
1572
|
*
|
|
1318
1573
|
* @param selectedOrGroupedCellId The Id of the Cell in the query to test.
|
|
1319
1574
|
* @param equals The value that the Cell has to have for the Row to be
|
|
1320
1575
|
* included in the result.
|
|
1321
1576
|
*/
|
|
1322
|
-
(selectedOrGroupedCellId: Id, equals:
|
|
1577
|
+
(selectedOrGroupedCellId: Id, equals: ResultCell): void;
|
|
1323
1578
|
/**
|
|
1324
1579
|
* Calling this function with one callback parameter is used to include only
|
|
1325
1580
|
* those Rows which meet a calculated boolean condition.
|
|
@@ -1327,7 +1582,7 @@ export type Having = {
|
|
|
1327
1582
|
* @param condition A callback that takes a GetCell function and that should
|
|
1328
1583
|
* return `true` for the Row to be included in the result.
|
|
1329
1584
|
*/
|
|
1330
|
-
(condition: (getSelectedOrGroupedCell:
|
|
1585
|
+
(condition: (getSelectedOrGroupedCell: GetResultCell) => boolean): void;
|
|
1331
1586
|
};
|
|
1332
1587
|
|
|
1333
1588
|
/**
|
|
@@ -1427,16 +1682,16 @@ export type Having = {
|
|
|
1427
1682
|
* @category Queries
|
|
1428
1683
|
* @since v2.0.0
|
|
1429
1684
|
*/
|
|
1430
|
-
export interface Queries {
|
|
1685
|
+
export interface Queries<in out Schemas extends OptionalSchemas> {
|
|
1431
1686
|
/**
|
|
1432
1687
|
* The setQueryDefinition method lets you set the definition of a query.
|
|
1433
1688
|
*
|
|
1434
1689
|
* Every query definition is identified by a unique Id, and if you re-use an
|
|
1435
1690
|
* existing Id with this method, the previous definition is overwritten.
|
|
1436
1691
|
*
|
|
1437
|
-
* A query provides a tabular result formed from each Row within a
|
|
1438
|
-
* The definition must specify this
|
|
1439
|
-
*
|
|
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.
|
|
1440
1695
|
*
|
|
1441
1696
|
* The third `query` parameter is a callback that you provide to define the
|
|
1442
1697
|
* query. That callback is provided with a `keywords` object that contains the
|
|
@@ -1452,7 +1707,7 @@ export interface Queries {
|
|
|
1452
1707
|
* filter results, based on the underlying Cells of the main or joined
|
|
1453
1708
|
* Tables.
|
|
1454
1709
|
* - The Group type describes a function that lets you specify that the values
|
|
1455
|
-
* of a Cell in multiple
|
|
1710
|
+
* of a Cell in multiple ResultRows should be aggregated together.
|
|
1456
1711
|
* - The Having type describes a function that lets you specify conditions to
|
|
1457
1712
|
* filter results, based on the grouped Cells resulting from a Group clause.
|
|
1458
1713
|
*
|
|
@@ -1463,7 +1718,7 @@ export interface Queries {
|
|
|
1463
1718
|
* addResultSortedRowIdsListener method to sort and paginate the results.
|
|
1464
1719
|
*
|
|
1465
1720
|
* @param queryId The Id of the query to define.
|
|
1466
|
-
* @param tableId The Id of the
|
|
1721
|
+
* @param tableId The Id of the root Table the query will be based on.
|
|
1467
1722
|
* @param query A callback which can take a `keywords` object and which uses
|
|
1468
1723
|
the functions it contains to define the query.
|
|
1469
1724
|
* @returns A reference to the Queries object.
|
|
@@ -1491,17 +1746,17 @@ export interface Queries {
|
|
|
1491
1746
|
* @category Configuration
|
|
1492
1747
|
* @since v2.0.0
|
|
1493
1748
|
*/
|
|
1494
|
-
setQueryDefinition(
|
|
1749
|
+
setQueryDefinition<RootTableId extends TableIdFromSchema<Schemas[0]>>(
|
|
1495
1750
|
queryId: Id,
|
|
1496
|
-
tableId:
|
|
1751
|
+
tableId: RootTableId,
|
|
1497
1752
|
query: (keywords: {
|
|
1498
|
-
select: Select
|
|
1499
|
-
join: Join
|
|
1500
|
-
where: Where
|
|
1753
|
+
select: Select<Schemas[0], RootTableId>;
|
|
1754
|
+
join: Join<Schemas[0], RootTableId>;
|
|
1755
|
+
where: Where<Schemas[0], RootTableId>;
|
|
1501
1756
|
group: Group;
|
|
1502
1757
|
having: Having;
|
|
1503
1758
|
}) => void,
|
|
1504
|
-
): Queries
|
|
1759
|
+
): Queries<Schemas>;
|
|
1505
1760
|
|
|
1506
1761
|
/**
|
|
1507
1762
|
* The delQueryDefinition method removes an existing query definition.
|
|
@@ -1534,7 +1789,7 @@ export interface Queries {
|
|
|
1534
1789
|
* @category Configuration
|
|
1535
1790
|
* @since v2.0.0
|
|
1536
1791
|
*/
|
|
1537
|
-
delQueryDefinition(queryId: Id): Queries
|
|
1792
|
+
delQueryDefinition(queryId: Id): Queries<Schemas>;
|
|
1538
1793
|
|
|
1539
1794
|
/**
|
|
1540
1795
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -1560,7 +1815,7 @@ export interface Queries {
|
|
|
1560
1815
|
* @category Getter
|
|
1561
1816
|
* @since v2.0.0
|
|
1562
1817
|
*/
|
|
1563
|
-
getStore(): Store
|
|
1818
|
+
getStore(): Store<Schemas>;
|
|
1564
1819
|
|
|
1565
1820
|
/**
|
|
1566
1821
|
* The getQueryIds method returns an array of the query Ids registered with
|
|
@@ -1684,11 +1939,13 @@ export interface Queries {
|
|
|
1684
1939
|
* @category Getter
|
|
1685
1940
|
* @since v2.0.0
|
|
1686
1941
|
*/
|
|
1687
|
-
getTableId
|
|
1942
|
+
getTableId<TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
1943
|
+
queryId: Id,
|
|
1944
|
+
): TableId | undefined;
|
|
1688
1945
|
|
|
1689
1946
|
/**
|
|
1690
1947
|
* The getResultTable method returns an object containing the entire data of
|
|
1691
|
-
* the
|
|
1948
|
+
* the ResultTable of the given query.
|
|
1692
1949
|
*
|
|
1693
1950
|
* This has the same behavior as a Store's getTable method. For example, if
|
|
1694
1951
|
* the query Id is invalid, the method returns an empty object. Similarly, it
|
|
@@ -1697,13 +1954,13 @@ export interface Queries {
|
|
|
1697
1954
|
* themselves.
|
|
1698
1955
|
*
|
|
1699
1956
|
* @param queryId The Id of a query.
|
|
1700
|
-
* @returns An object containing the entire data of the
|
|
1957
|
+
* @returns An object containing the entire data of the ResultTable of the
|
|
1701
1958
|
* query.
|
|
1702
|
-
* @returns The result of the query, structured as a
|
|
1959
|
+
* @returns The result of the query, structured as a ResultTable.
|
|
1703
1960
|
* @example
|
|
1704
1961
|
* This example creates a Queries object, a single query definition, and then
|
|
1705
1962
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1706
|
-
*
|
|
1963
|
+
* ResultTable.
|
|
1707
1964
|
*
|
|
1708
1965
|
* ```js
|
|
1709
1966
|
* const store = createStore().setTable('pets', {
|
|
@@ -1730,11 +1987,11 @@ export interface Queries {
|
|
|
1730
1987
|
* @category Result
|
|
1731
1988
|
* @since v2.0.0
|
|
1732
1989
|
*/
|
|
1733
|
-
getResultTable(queryId: Id):
|
|
1990
|
+
getResultTable(queryId: Id): ResultTable;
|
|
1734
1991
|
|
|
1735
1992
|
/**
|
|
1736
|
-
* The getResultRowIds method returns the Ids of every
|
|
1737
|
-
* of the given query.
|
|
1993
|
+
* The getResultRowIds method returns the Ids of every ResultRow in the
|
|
1994
|
+
* ResultTable of the given query.
|
|
1738
1995
|
*
|
|
1739
1996
|
* This has the same behavior as a Store's getRowIds method. For example, if
|
|
1740
1997
|
* the query Id is invalid, the method returns an empty array. Similarly, it
|
|
@@ -1742,11 +1999,11 @@ export interface Queries {
|
|
|
1742
1999
|
* made to the list object are not made to the query results themselves.
|
|
1743
2000
|
*
|
|
1744
2001
|
* @param queryId The Id of a query.
|
|
1745
|
-
* @returns An array of the Ids of every
|
|
2002
|
+
* @returns An array of the Ids of every ResultRow in the result of the query.
|
|
1746
2003
|
* @example
|
|
1747
2004
|
* This example creates a Queries object, a single query definition, and then
|
|
1748
2005
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1749
|
-
*
|
|
2006
|
+
* ResultRow Ids.
|
|
1750
2007
|
*
|
|
1751
2008
|
* ```js
|
|
1752
2009
|
* const store = createStore().setTable('pets', {
|
|
@@ -1776,37 +2033,37 @@ export interface Queries {
|
|
|
1776
2033
|
getResultRowIds(queryId: Id): Ids;
|
|
1777
2034
|
|
|
1778
2035
|
/**
|
|
1779
|
-
* The getResultSortedRowIds method returns the Ids of every
|
|
1780
|
-
*
|
|
1781
|
-
*
|
|
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.
|
|
1782
2039
|
*
|
|
1783
2040
|
* This has the same behavior as a Store's getSortedRowIds method. For
|
|
1784
2041
|
* example, if the query Id is invalid, the method returns an empty array.
|
|
1785
2042
|
* Similarly, the sorting of the rows is alphanumeric, and you can indicate
|
|
1786
2043
|
* whether it should be in descending order. The `offset` and `limit`
|
|
1787
2044
|
* parameters are used to paginate results, but default to `0` and `undefined`
|
|
1788
|
-
* to return all available
|
|
2045
|
+
* to return all available ResultRow Ids if not specified.
|
|
1789
2046
|
*
|
|
1790
2047
|
* Note that every call to this method will perform the sorting afresh - there
|
|
1791
2048
|
* is no caching of the results - and so you are advised to memoize the
|
|
1792
|
-
* results yourself, especially when the
|
|
1793
|
-
* performant approach to tracking the sorted
|
|
1794
|
-
* 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.
|
|
1795
2052
|
*
|
|
1796
2053
|
* @param queryId The Id of a query.
|
|
1797
|
-
* @param cellId The Id of the
|
|
1798
|
-
* `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.
|
|
1799
2056
|
* @param descending Whether the sorting should be in descending order.
|
|
1800
|
-
* @param offset The number of
|
|
1801
|
-
* any.
|
|
1802
|
-
* @param limit The maximum number of
|
|
1803
|
-
* all.
|
|
1804
|
-
* @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
|
|
1805
2062
|
* query.
|
|
1806
2063
|
* @example
|
|
1807
2064
|
* This example creates a Queries object, a single query definition, and then
|
|
1808
2065
|
* calls this method on it (as well as a non-existent definition) to get the
|
|
1809
|
-
*
|
|
2066
|
+
* ResultRow Ids.
|
|
1810
2067
|
*
|
|
1811
2068
|
* ```js
|
|
1812
2069
|
* const store = createStore().setTable('pets', {
|
|
@@ -1843,22 +2100,22 @@ export interface Queries {
|
|
|
1843
2100
|
|
|
1844
2101
|
/**
|
|
1845
2102
|
* The getResultRow method returns an object containing the entire data of a
|
|
1846
|
-
* single
|
|
2103
|
+
* single ResultRow in the ResultTable of the given query.
|
|
1847
2104
|
*
|
|
1848
2105
|
* This has the same behavior as a Store's getRow method. For example, if the
|
|
1849
|
-
* query or
|
|
1850
|
-
* it returns a copy of, rather than a reference to the underlying
|
|
1851
|
-
* changes made to the returned object are not made to the query
|
|
1852
|
-
* 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.
|
|
1853
2110
|
*
|
|
1854
2111
|
* @param queryId The Id of a query.
|
|
1855
|
-
* @param rowId The Id of the
|
|
1856
|
-
* @returns An object containing the entire data of the
|
|
1857
|
-
*
|
|
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.
|
|
1858
2115
|
* @example
|
|
1859
2116
|
* This example creates a Queries object, a single query definition, and then
|
|
1860
|
-
* calls this method on it (as well as a non-existent
|
|
1861
|
-
*
|
|
2117
|
+
* calls this method on it (as well as a non-existent ResultRow Id) to get
|
|
2118
|
+
* the ResultRow.
|
|
1862
2119
|
*
|
|
1863
2120
|
* ```js
|
|
1864
2121
|
* const store = createStore().setTable('pets', {
|
|
@@ -1885,26 +2142,26 @@ export interface Queries {
|
|
|
1885
2142
|
* @category Result
|
|
1886
2143
|
* @since v2.0.0
|
|
1887
2144
|
*/
|
|
1888
|
-
getResultRow(queryId: Id, rowId: Id):
|
|
2145
|
+
getResultRow(queryId: Id, rowId: Id): ResultRow;
|
|
1889
2146
|
|
|
1890
2147
|
/**
|
|
1891
|
-
* The getResultCellIds method returns the Ids of every
|
|
1892
|
-
* in the
|
|
2148
|
+
* The getResultCellIds method returns the Ids of every ResultCell in a given
|
|
2149
|
+
* ResultRow, in the ResultTable of the given query.
|
|
1893
2150
|
*
|
|
1894
2151
|
* This has the same behavior as a Store's getCellIds method. For example, if
|
|
1895
|
-
* the query Id or
|
|
2152
|
+
* the query Id or ResultRow Id is invalid, the method returns an empty array.
|
|
1896
2153
|
* Similarly, it returns a copy of, rather than a reference to the list of
|
|
1897
2154
|
* Ids, so changes made to the list object are not made to the query results
|
|
1898
2155
|
* themselves.
|
|
1899
2156
|
*
|
|
1900
2157
|
* @param queryId The Id of a query.
|
|
1901
|
-
* @param rowId The Id of the
|
|
1902
|
-
* @returns An array of the Ids of every
|
|
1903
|
-
* 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.
|
|
1904
2161
|
* @example
|
|
1905
2162
|
* This example creates a Queries object, a single query definition, and then
|
|
1906
|
-
* calls this method on it (as well as a non-existent
|
|
1907
|
-
*
|
|
2163
|
+
* calls this method on it (as well as a non-existent ResultRow Id) to get the
|
|
2164
|
+
* ResultCell Ids.
|
|
1908
2165
|
*
|
|
1909
2166
|
* ```js
|
|
1910
2167
|
* const store = createStore().setTable('pets', {
|
|
@@ -1934,20 +2191,21 @@ export interface Queries {
|
|
|
1934
2191
|
getResultCellIds(queryId: Id, rowId: Id): Ids;
|
|
1935
2192
|
|
|
1936
2193
|
/**
|
|
1937
|
-
* The getResultCell method returns the value of a single
|
|
1938
|
-
* 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.
|
|
1939
2196
|
*
|
|
1940
2197
|
* This has the same behavior as a Store's getCell method. For example, if the
|
|
1941
|
-
* query, or
|
|
2198
|
+
* query, or ResultRow, or ResultCell Id is invalid, the method returns
|
|
2199
|
+
* `undefined`.
|
|
1942
2200
|
*
|
|
1943
2201
|
* @param queryId The Id of a query.
|
|
1944
|
-
* @param rowId The Id of the
|
|
1945
|
-
* @param cellId The Id of the
|
|
1946
|
-
* @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`.
|
|
1947
2205
|
* @example
|
|
1948
2206
|
* This example creates a Queries object, a single query definition, and then
|
|
1949
|
-
* calls this method on it (as well as a non-existent
|
|
1950
|
-
*
|
|
2207
|
+
* calls this method on it (as well as a non-existent ResultCell Id) to get
|
|
2208
|
+
* the ResultCell.
|
|
1951
2209
|
*
|
|
1952
2210
|
* ```js
|
|
1953
2211
|
* const store = createStore().setTable('pets', {
|
|
@@ -1974,16 +2232,16 @@ export interface Queries {
|
|
|
1974
2232
|
* @category Result
|
|
1975
2233
|
* @since v2.0.0
|
|
1976
2234
|
*/
|
|
1977
|
-
getResultCell(queryId: Id, rowId: Id, cellId: Id):
|
|
2235
|
+
getResultCell(queryId: Id, rowId: Id, cellId: Id): ResultCellOrUndefined;
|
|
1978
2236
|
|
|
1979
2237
|
/**
|
|
1980
2238
|
* The hasResultTable method returns a boolean indicating whether a given
|
|
1981
|
-
*
|
|
2239
|
+
* ResultTable exists.
|
|
1982
2240
|
*
|
|
1983
2241
|
* @param queryId The Id of a possible query.
|
|
1984
|
-
* @returns Whether a
|
|
2242
|
+
* @returns Whether a ResultTable for that query Id exists.
|
|
1985
2243
|
* @example
|
|
1986
|
-
* This example shows two simple
|
|
2244
|
+
* This example shows two simple ResultTable existence checks.
|
|
1987
2245
|
*
|
|
1988
2246
|
* ```js
|
|
1989
2247
|
* const store = createStore().setTable('pets', {
|
|
@@ -2012,14 +2270,14 @@ export interface Queries {
|
|
|
2012
2270
|
hasResultTable(queryId: Id): boolean;
|
|
2013
2271
|
|
|
2014
2272
|
/**
|
|
2015
|
-
* The hasResultRow method returns a boolean indicating whether a given
|
|
2016
|
-
*
|
|
2273
|
+
* The hasResultRow method returns a boolean indicating whether a given
|
|
2274
|
+
* ResultRow exists.
|
|
2017
2275
|
*
|
|
2018
2276
|
* @param queryId The Id of a possible query.
|
|
2019
|
-
* @param rowId The Id of a possible
|
|
2020
|
-
* @returns Whether a
|
|
2277
|
+
* @param rowId The Id of a possible ResultRow.
|
|
2278
|
+
* @returns Whether a ResultRow for that Id exists.
|
|
2021
2279
|
* @example
|
|
2022
|
-
* This example shows two simple
|
|
2280
|
+
* This example shows two simple ResultRow existence checks.
|
|
2023
2281
|
*
|
|
2024
2282
|
* ```js
|
|
2025
2283
|
* const store = createStore().setTable('pets', {
|
|
@@ -2049,14 +2307,14 @@ export interface Queries {
|
|
|
2049
2307
|
|
|
2050
2308
|
/**
|
|
2051
2309
|
* The hasResultCell method returns a boolean indicating whether a given
|
|
2052
|
-
*
|
|
2310
|
+
* ResultCell exists.
|
|
2053
2311
|
*
|
|
2054
2312
|
* @param queryId The Id of a possible query.
|
|
2055
|
-
* @param rowId The Id of a possible
|
|
2056
|
-
* @param cellId The Id of a possible
|
|
2057
|
-
* @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.
|
|
2058
2316
|
* @example
|
|
2059
|
-
* This example shows two simple
|
|
2317
|
+
* This example shows two simple ResultRow existence checks.
|
|
2060
2318
|
*
|
|
2061
2319
|
* ```js
|
|
2062
2320
|
* const store = createStore().setTable('pets', {
|
|
@@ -2086,18 +2344,18 @@ export interface Queries {
|
|
|
2086
2344
|
|
|
2087
2345
|
/**
|
|
2088
2346
|
* The forEachResultTable method takes a function that it will then call for
|
|
2089
|
-
* each
|
|
2347
|
+
* each ResultTable in the Queries object.
|
|
2090
2348
|
*
|
|
2091
|
-
* This method is useful for iterating over all the
|
|
2349
|
+
* This method is useful for iterating over all the ResultTables of the
|
|
2092
2350
|
* queries in a functional style. The `tableCallback` parameter is a
|
|
2093
|
-
*
|
|
2094
|
-
*
|
|
2095
|
-
* 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.
|
|
2096
2354
|
*
|
|
2097
2355
|
* @param tableCallback The function that should be called for every query's
|
|
2098
|
-
*
|
|
2356
|
+
* ResultTable.
|
|
2099
2357
|
* @example
|
|
2100
|
-
* This example iterates over each query's
|
|
2358
|
+
* This example iterates over each query's ResultTable in a Queries object.
|
|
2101
2359
|
*
|
|
2102
2360
|
* ```js
|
|
2103
2361
|
* const store = createStore().setTable('pets', {
|
|
@@ -2129,23 +2387,23 @@ export interface Queries {
|
|
|
2129
2387
|
* @category Iterator
|
|
2130
2388
|
* @since v2.0.0
|
|
2131
2389
|
*/
|
|
2132
|
-
forEachResultTable(tableCallback:
|
|
2390
|
+
forEachResultTable(tableCallback: ResultTableCallback): void;
|
|
2133
2391
|
|
|
2134
2392
|
/**
|
|
2135
2393
|
* The forEachResultRow method takes a function that it will then call for
|
|
2136
|
-
* each
|
|
2394
|
+
* each ResultRow in the ResultTable of a query.
|
|
2137
2395
|
*
|
|
2138
|
-
* This method is useful for iterating over each
|
|
2139
|
-
* the query in a functional style. The `rowCallback` parameter is a
|
|
2140
|
-
*
|
|
2141
|
-
* and with a function that can then be used to iterate over each
|
|
2142
|
-
*
|
|
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.
|
|
2143
2401
|
*
|
|
2144
2402
|
* @param queryId The Id of a query.
|
|
2145
|
-
* @param rowCallback The function that should be called for every
|
|
2146
|
-
* query's
|
|
2403
|
+
* @param rowCallback The function that should be called for every ResultRow
|
|
2404
|
+
* of the query's ResultTable.
|
|
2147
2405
|
* @example
|
|
2148
|
-
* This example iterates over each
|
|
2406
|
+
* This example iterates over each ResultRow in a query's ResultTable.
|
|
2149
2407
|
*
|
|
2150
2408
|
* ```js
|
|
2151
2409
|
* const store = createStore().setTable('pets', {
|
|
@@ -2175,22 +2433,23 @@ export interface Queries {
|
|
|
2175
2433
|
* @category Iterator
|
|
2176
2434
|
* @since v2.0.0
|
|
2177
2435
|
*/
|
|
2178
|
-
forEachResultRow(queryId: Id, rowCallback:
|
|
2436
|
+
forEachResultRow(queryId: Id, rowCallback: ResultRowCallback): void;
|
|
2179
2437
|
|
|
2180
2438
|
/**
|
|
2181
2439
|
* The forEachResultCell method takes a function that it will then call for
|
|
2182
|
-
* each
|
|
2440
|
+
* each ResultCell in the ResultRow of a query.
|
|
2183
2441
|
*
|
|
2184
|
-
* This method is useful for iterating over each
|
|
2185
|
-
* query in a functional style. The `cellCallback` parameter is a
|
|
2186
|
-
* 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.
|
|
2187
2446
|
*
|
|
2188
2447
|
* @param queryId The Id of a query.
|
|
2189
|
-
* @param rowId The Id of a
|
|
2190
|
-
* @param cellCallback The function that should be called for every
|
|
2191
|
-
* 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.
|
|
2192
2451
|
* @example
|
|
2193
|
-
* This example iterates over each
|
|
2452
|
+
* This example iterates over each ResultCell in a query's ResultRow.
|
|
2194
2453
|
*
|
|
2195
2454
|
* ```js
|
|
2196
2455
|
* const store = createStore().setTable('pets', {
|
|
@@ -2218,28 +2477,32 @@ export interface Queries {
|
|
|
2218
2477
|
* @category Iterator
|
|
2219
2478
|
* @since v2.0.0
|
|
2220
2479
|
*/
|
|
2221
|
-
forEachResultCell(
|
|
2480
|
+
forEachResultCell(
|
|
2481
|
+
queryId: Id,
|
|
2482
|
+
rowId: Id,
|
|
2483
|
+
cellCallback: ResultCellCallback,
|
|
2484
|
+
): void;
|
|
2222
2485
|
|
|
2223
2486
|
/**
|
|
2224
2487
|
* The addResultTableListener method registers a listener function with the
|
|
2225
|
-
* Queries object that will be called whenever data in a
|
|
2488
|
+
* Queries object that will be called whenever data in a ResultTable changes.
|
|
2226
2489
|
*
|
|
2227
2490
|
* The provided listener is a ResultTableListener function, and will be called
|
|
2228
|
-
* with a reference to the Queries object, the Id of the
|
|
2229
|
-
* (which is also the query Id), and a
|
|
2230
|
-
* 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.
|
|
2231
2494
|
*
|
|
2232
|
-
* You can either listen to a single
|
|
2233
|
-
* the method's first parameter) or changes to any
|
|
2234
|
-
*
|
|
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).
|
|
2235
2498
|
*
|
|
2236
2499
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2237
2500
|
* @param listener The function that will be called whenever data in the
|
|
2238
|
-
* matching
|
|
2501
|
+
* matching ResultTable changes.
|
|
2239
2502
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2240
2503
|
* @example
|
|
2241
2504
|
* This example registers a listener that responds to any changes to a
|
|
2242
|
-
* specific
|
|
2505
|
+
* specific ResultTable.
|
|
2243
2506
|
*
|
|
2244
2507
|
* ```js
|
|
2245
2508
|
* const store = createStore().setTable('pets', {
|
|
@@ -2273,7 +2536,7 @@ export interface Queries {
|
|
|
2273
2536
|
* ```
|
|
2274
2537
|
* @example
|
|
2275
2538
|
* This example registers a listener that responds to any changes to any
|
|
2276
|
-
*
|
|
2539
|
+
* ResultTable.
|
|
2277
2540
|
*
|
|
2278
2541
|
* ```js
|
|
2279
2542
|
* const store = createStore().setTable('pets', {
|
|
@@ -2309,32 +2572,35 @@ export interface Queries {
|
|
|
2309
2572
|
* @category Listener
|
|
2310
2573
|
* @since v2.0.0
|
|
2311
2574
|
*/
|
|
2312
|
-
addResultTableListener(
|
|
2575
|
+
addResultTableListener(
|
|
2576
|
+
queryId: IdOrNull,
|
|
2577
|
+
listener: ResultTableListener<Schemas>,
|
|
2578
|
+
): Id;
|
|
2313
2579
|
|
|
2314
2580
|
/**
|
|
2315
2581
|
* The addResultRowIdsListener method registers a listener function with the
|
|
2316
|
-
* Queries object that will be called whenever the
|
|
2317
|
-
* change.
|
|
2582
|
+
* Queries object that will be called whenever the ResultRow Ids in a
|
|
2583
|
+
* ResultTable change.
|
|
2318
2584
|
*
|
|
2319
2585
|
* The provided listener is a ResultRowIdsListener function, and will be
|
|
2320
|
-
* called with a reference to the Queries object and the Id of the
|
|
2321
|
-
* 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).
|
|
2322
2588
|
*
|
|
2323
|
-
* By default, such a listener is only called when a
|
|
2324
|
-
* removed from, the
|
|
2325
|
-
*
|
|
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.
|
|
2326
2592
|
*
|
|
2327
|
-
* You can either listen to a single
|
|
2328
|
-
* the method's first parameter) or changes to any
|
|
2329
|
-
*
|
|
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).
|
|
2330
2596
|
*
|
|
2331
2597
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2332
|
-
* @param listener The function that will be called whenever the
|
|
2333
|
-
* the
|
|
2598
|
+
* @param listener The function that will be called whenever the ResultRow Ids
|
|
2599
|
+
* in the ResultTable change.
|
|
2334
2600
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2335
2601
|
* @example
|
|
2336
|
-
* This example registers a listener that responds to any change to the
|
|
2337
|
-
* Ids of a specific
|
|
2602
|
+
* This example registers a listener that responds to any change to the
|
|
2603
|
+
* ResultRow Ids of a specific ResultTable.
|
|
2338
2604
|
*
|
|
2339
2605
|
* ```js
|
|
2340
2606
|
* const store = createStore().setTable('pets', {
|
|
@@ -2367,8 +2633,8 @@ export interface Queries {
|
|
|
2367
2633
|
* store.delListener(listenerId);
|
|
2368
2634
|
* ```
|
|
2369
2635
|
* @example
|
|
2370
|
-
* This example registers a listener that responds to any change to the
|
|
2371
|
-
* Ids of any
|
|
2636
|
+
* This example registers a listener that responds to any change to the
|
|
2637
|
+
* ResultRow Ids of any ResultTable.
|
|
2372
2638
|
*
|
|
2373
2639
|
* ```js
|
|
2374
2640
|
* const store = createStore().setTable('pets', {
|
|
@@ -2406,50 +2672,50 @@ export interface Queries {
|
|
|
2406
2672
|
*/
|
|
2407
2673
|
addResultRowIdsListener(
|
|
2408
2674
|
queryId: IdOrNull,
|
|
2409
|
-
listener: ResultRowIdsListener
|
|
2675
|
+
listener: ResultRowIdsListener<Schemas>,
|
|
2410
2676
|
): Id;
|
|
2411
2677
|
|
|
2412
2678
|
/**
|
|
2413
2679
|
* The addResultSortedRowIdsListener method registers a listener function with
|
|
2414
2680
|
* the Queries object that will be called whenever sorted (and optionally,
|
|
2415
|
-
* paginated)
|
|
2681
|
+
* paginated) ResultRow Ids in a ResultTable change.
|
|
2416
2682
|
*
|
|
2417
2683
|
* The provided listener is a ResultSortedRowIdsListener function, and will be
|
|
2418
|
-
* called with a reference to the Queries object, the Id of the
|
|
2419
|
-
* whose
|
|
2420
|
-
* being used to sort them, whether descending or not, and the
|
|
2421
|
-
* limit of the number of Ids returned, for pagination purposes. It
|
|
2422
|
-
* receives the sorted array of Ids itself, so that you can use them in
|
|
2423
|
-
* 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
|
|
2424
2690
|
* getResultSortedRowIds
|
|
2425
2691
|
*
|
|
2426
|
-
* Such a listener is called when a
|
|
2427
|
-
* value in the specified
|
|
2428
|
-
* 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.
|
|
2429
2695
|
*
|
|
2430
2696
|
* Unlike most other listeners, you cannot provide wildcards (due to the cost
|
|
2431
2697
|
* of detecting changes to the sorting). You can only listen to a single
|
|
2432
|
-
* specified
|
|
2698
|
+
* specified ResultTable, sorted by a single specified ResultCell.
|
|
2433
2699
|
*
|
|
2434
2700
|
* The sorting of the rows is alphanumeric, and you can indicate whether it
|
|
2435
2701
|
* should be in descending order. The `offset` and `limit` parameters are used
|
|
2436
2702
|
* to paginate results, but default to `0` and `undefined` to return all
|
|
2437
|
-
* available
|
|
2703
|
+
* available ResultRow Ids if not specified.
|
|
2438
2704
|
*
|
|
2439
2705
|
* @param queryId The Id of the query to listen to.
|
|
2440
|
-
* @param cellId The Id of the
|
|
2441
|
-
* `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.
|
|
2442
2708
|
* @param descending Whether the sorting should be in descending order.
|
|
2443
|
-
* @param offset The number of
|
|
2444
|
-
* any.
|
|
2445
|
-
* @param limit The maximum number of
|
|
2446
|
-
* all.
|
|
2447
|
-
* @param listener The function that will be called whenever the sorted
|
|
2448
|
-
* 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.
|
|
2449
2715
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2450
2716
|
* @example
|
|
2451
2717
|
* This example registers a listener that responds to any change to the sorted
|
|
2452
|
-
*
|
|
2718
|
+
* ResultRow Ids of a specific ResultTable.
|
|
2453
2719
|
*
|
|
2454
2720
|
* ```js
|
|
2455
2721
|
* const store = createStore().setTable('pets', {
|
|
@@ -2474,22 +2740,22 @@ export interface Queries {
|
|
|
2474
2740
|
* 0,
|
|
2475
2741
|
* undefined,
|
|
2476
2742
|
* (queries, tableId, cellId, descending, offset, limit, sortedRowIds) => {
|
|
2477
|
-
* console.log(`Sorted
|
|
2743
|
+
* console.log(`Sorted row Ids for dogColors result table changed`);
|
|
2478
2744
|
* console.log(sortedRowIds);
|
|
2479
2745
|
* // ^ cheaper than calling getResultSortedRowIds again
|
|
2480
2746
|
* },
|
|
2481
2747
|
* );
|
|
2482
2748
|
*
|
|
2483
2749
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'});
|
|
2484
|
-
* // -> 'Sorted
|
|
2750
|
+
* // -> 'Sorted row Ids for dogColors result table changed'
|
|
2485
2751
|
* // -> ['cujo', 'fido', 'rex']
|
|
2486
2752
|
*
|
|
2487
2753
|
* store.delListener(listenerId);
|
|
2488
2754
|
* ```
|
|
2489
2755
|
* @example
|
|
2490
2756
|
* This example registers a listener that responds to any change to the sorted
|
|
2491
|
-
*
|
|
2492
|
-
* 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.
|
|
2493
2759
|
*
|
|
2494
2760
|
* ```js
|
|
2495
2761
|
* const store = createStore().setTable('pets', {
|
|
@@ -2516,14 +2782,14 @@ export interface Queries {
|
|
|
2516
2782
|
* 0,
|
|
2517
2783
|
* undefined,
|
|
2518
2784
|
* (queries, tableId, cellId, descending, offset, limit, sortedRowIds) => {
|
|
2519
|
-
* console.log(`Sorted
|
|
2785
|
+
* console.log(`Sorted row Ids for dogColors result table changed`);
|
|
2520
2786
|
* console.log(sortedRowIds);
|
|
2521
2787
|
* // ^ cheaper than calling getSortedRowIds again
|
|
2522
2788
|
* },
|
|
2523
2789
|
* );
|
|
2524
2790
|
*
|
|
2525
2791
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'});
|
|
2526
|
-
* // -> 'Sorted
|
|
2792
|
+
* // -> 'Sorted row Ids for dogColors result table changed'
|
|
2527
2793
|
* // -> ['cujo', 'fido', 'rex']
|
|
2528
2794
|
*
|
|
2529
2795
|
* store.delListener(listenerId);
|
|
@@ -2537,36 +2803,35 @@ export interface Queries {
|
|
|
2537
2803
|
descending: boolean,
|
|
2538
2804
|
offset: number,
|
|
2539
2805
|
limit: number | undefined,
|
|
2540
|
-
listener: ResultSortedRowIdsListener
|
|
2806
|
+
listener: ResultSortedRowIdsListener<Schemas>,
|
|
2541
2807
|
): Id;
|
|
2542
2808
|
|
|
2543
2809
|
/**
|
|
2544
2810
|
* The addResultRowListener method registers a listener function with the
|
|
2545
|
-
* Queries object that will be called whenever data in a
|
|
2811
|
+
* Queries object that will be called whenever data in a ResultRow changes.
|
|
2546
2812
|
*
|
|
2547
2813
|
* The provided listener is a ResultRowListener function, and will be called
|
|
2548
|
-
* with a reference to the Queries object, the Id of the
|
|
2549
|
-
* (which is also the query Id), and a
|
|
2550
|
-
* 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.
|
|
2551
2817
|
*
|
|
2552
|
-
* You can either listen to a single
|
|
2553
|
-
*
|
|
2554
|
-
* (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).
|
|
2555
2821
|
*
|
|
2556
2822
|
* Both, either, or neither of the `queryId` and `rowId` parameters can be
|
|
2557
|
-
* wildcarded with `null`. You can listen to a specific
|
|
2558
|
-
* specific query, any
|
|
2559
|
-
*
|
|
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.
|
|
2560
2826
|
*
|
|
2561
2827
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2562
|
-
* @param rowId The Id of the
|
|
2563
|
-
* wildcard.
|
|
2828
|
+
* @param rowId The Id of the ResultRow to listen to, or `null` as a wildcard.
|
|
2564
2829
|
* @param listener The function that will be called whenever data in the
|
|
2565
|
-
* matching
|
|
2830
|
+
* matching ResultRow changes.
|
|
2566
2831
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2567
2832
|
* @example
|
|
2568
2833
|
* This example registers a listener that responds to any changes to a
|
|
2569
|
-
* specific
|
|
2834
|
+
* specific ResultRow.
|
|
2570
2835
|
*
|
|
2571
2836
|
* ```js
|
|
2572
2837
|
* const store = createStore().setTable('pets', {
|
|
@@ -2601,7 +2866,7 @@ export interface Queries {
|
|
|
2601
2866
|
* ```
|
|
2602
2867
|
* @example
|
|
2603
2868
|
* This example registers a listener that responds to any changes to any
|
|
2604
|
-
*
|
|
2869
|
+
* ResultRow.
|
|
2605
2870
|
*
|
|
2606
2871
|
* ```js
|
|
2607
2872
|
* const store = createStore().setTable('pets', {
|
|
@@ -2641,40 +2906,39 @@ export interface Queries {
|
|
|
2641
2906
|
addResultRowListener(
|
|
2642
2907
|
queryId: IdOrNull,
|
|
2643
2908
|
rowId: IdOrNull,
|
|
2644
|
-
listener: ResultRowListener
|
|
2909
|
+
listener: ResultRowListener<Schemas>,
|
|
2645
2910
|
): Id;
|
|
2646
2911
|
|
|
2647
2912
|
/**
|
|
2648
2913
|
* The addResultCellIdsListener method registers a listener function with the
|
|
2649
|
-
* Queries object that will be called whenever the
|
|
2650
|
-
* change.
|
|
2914
|
+
* Queries object that will be called whenever the ResultCell Ids in a
|
|
2915
|
+
* ResultRow change.
|
|
2651
2916
|
*
|
|
2652
2917
|
* The provided listener is a ResultCellIdsListener function, and will be
|
|
2653
|
-
* called with a reference to the Queries object, the Id of the
|
|
2654
|
-
* 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.
|
|
2655
2920
|
*
|
|
2656
|
-
* Such a listener is only called when a
|
|
2657
|
-
* 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
|
|
2658
2923
|
* addResultRowListener method.
|
|
2659
2924
|
*
|
|
2660
|
-
* You can either listen to a single
|
|
2661
|
-
*
|
|
2662
|
-
* 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).
|
|
2663
2928
|
*
|
|
2664
2929
|
* Both, either, or neither of the `queryId` and `rowId` parameters can be
|
|
2665
|
-
* wildcarded with `null`. You can listen to a specific
|
|
2666
|
-
* specific query, any
|
|
2667
|
-
*
|
|
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.
|
|
2668
2933
|
*
|
|
2669
2934
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2670
|
-
* @param rowId The Id of the
|
|
2671
|
-
*
|
|
2672
|
-
*
|
|
2673
|
-
* 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.
|
|
2674
2938
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2675
2939
|
* @example
|
|
2676
|
-
* This example registers a listener that responds to any change to the
|
|
2677
|
-
* Ids of a specific
|
|
2940
|
+
* This example registers a listener that responds to any change to the
|
|
2941
|
+
* ResultCell Ids of a specific ResultRow.
|
|
2678
2942
|
*
|
|
2679
2943
|
* ```js
|
|
2680
2944
|
* const store = createStore().setTable('pets', {
|
|
@@ -2709,8 +2973,8 @@ export interface Queries {
|
|
|
2709
2973
|
* store.delListener(listenerId);
|
|
2710
2974
|
* ```
|
|
2711
2975
|
* @example
|
|
2712
|
-
* This example registers a listener that responds to any change to the
|
|
2713
|
-
* Ids of any
|
|
2976
|
+
* This example registers a listener that responds to any change to the
|
|
2977
|
+
* ResultCell Ids of any ResultRow.
|
|
2714
2978
|
*
|
|
2715
2979
|
* ```js
|
|
2716
2980
|
* const store = createStore().setTable('pets', {
|
|
@@ -2754,40 +3018,39 @@ export interface Queries {
|
|
|
2754
3018
|
addResultCellIdsListener(
|
|
2755
3019
|
queryId: IdOrNull,
|
|
2756
3020
|
rowId: IdOrNull,
|
|
2757
|
-
listener: ResultCellIdsListener
|
|
3021
|
+
listener: ResultCellIdsListener<Schemas>,
|
|
2758
3022
|
): Id;
|
|
2759
3023
|
|
|
2760
3024
|
/**
|
|
2761
3025
|
* The addResultCellListener method registers a listener function with the
|
|
2762
|
-
* Queries object that will be called whenever data in a
|
|
3026
|
+
* Queries object that will be called whenever data in a ResultCell changes.
|
|
2763
3027
|
*
|
|
2764
3028
|
* The provided listener is a ResultCellListener function, and will be called
|
|
2765
|
-
* with a reference to the Queries object, the Id of the
|
|
2766
|
-
* (which is also the query Id), the Id of the
|
|
2767
|
-
*
|
|
2768
|
-
*
|
|
2769
|
-
* 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.
|
|
2770
3034
|
*
|
|
2771
|
-
* You can either listen to a single
|
|
2772
|
-
* Id, and
|
|
2773
|
-
*
|
|
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).
|
|
2774
3038
|
*
|
|
2775
3039
|
* All, some, or none of the `queryId`, `rowId`, and `cellId` parameters can
|
|
2776
|
-
* be wildcarded with `null`. You can listen to a specific
|
|
2777
|
-
*
|
|
2778
|
-
* 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.
|
|
2779
3043
|
*
|
|
2780
3044
|
* @param queryId The Id of the query to listen to, or `null` as a wildcard.
|
|
2781
|
-
* @param rowId The Id of the
|
|
2782
|
-
*
|
|
2783
|
-
* @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
|
|
2784
3047
|
* wildcard.
|
|
2785
3048
|
* @param listener The function that will be called whenever data in the
|
|
2786
|
-
* matching
|
|
3049
|
+
* matching ResultCell changes.
|
|
2787
3050
|
* @returns A unique Id for the listener that can later be used to remove it.
|
|
2788
3051
|
* @example
|
|
2789
3052
|
* This example registers a listener that responds to any changes to a
|
|
2790
|
-
* specific
|
|
3053
|
+
* specific ResultCell.
|
|
2791
3054
|
*
|
|
2792
3055
|
* ```js
|
|
2793
3056
|
* const store = createStore().setTable('pets', {
|
|
@@ -2827,7 +3090,7 @@ export interface Queries {
|
|
|
2827
3090
|
* ```
|
|
2828
3091
|
* @example
|
|
2829
3092
|
* This example registers a listener that responds to any changes to any
|
|
2830
|
-
*
|
|
3093
|
+
* ResultCell.
|
|
2831
3094
|
*
|
|
2832
3095
|
* ```js
|
|
2833
3096
|
* const store = createStore().setTable('pets', {
|
|
@@ -2872,7 +3135,7 @@ export interface Queries {
|
|
|
2872
3135
|
queryId: IdOrNull,
|
|
2873
3136
|
rowId: IdOrNull,
|
|
2874
3137
|
cellId: IdOrNull,
|
|
2875
|
-
listener: ResultCellListener
|
|
3138
|
+
listener: ResultCellListener<Schemas>,
|
|
2876
3139
|
): Id;
|
|
2877
3140
|
|
|
2878
3141
|
/**
|
|
@@ -2919,7 +3182,7 @@ export interface Queries {
|
|
|
2919
3182
|
* @category Listener
|
|
2920
3183
|
* @since v2.0.0
|
|
2921
3184
|
*/
|
|
2922
|
-
delListener(listenerId: Id): Queries
|
|
3185
|
+
delListener(listenerId: Id): Queries<Schemas>;
|
|
2923
3186
|
|
|
2924
3187
|
/**
|
|
2925
3188
|
* The destroy method should be called when this Queries object is no longer
|
|
@@ -3021,4 +3284,6 @@ export interface Queries {
|
|
|
3021
3284
|
* @category Creation
|
|
3022
3285
|
* @since v2.0.0
|
|
3023
3286
|
*/
|
|
3024
|
-
export function createQueries
|
|
3287
|
+
export function createQueries<Schemas extends OptionalSchemas>(
|
|
3288
|
+
store: Store<Schemas>,
|
|
3289
|
+
): Queries<Schemas>;
|