tinybase 0.9.2 → 1.0.1

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The persisters module of the TinyBase project provides a simple framework
3
- * for saving and loading Store data, to and from different destinations, or
2
+ * The persisters module of the TinyBase project provides a simple framework for
3
+ * saving and loading Store data, to and from different destinations, or
4
4
  * underlying storage types.
5
5
  *
6
6
  * Several entry points are provided, each of which returns a new Persister
@@ -11,20 +11,24 @@
11
11
  * - The createLocalPersister function returns a Persister that uses the
12
12
  * browser's local storage.
13
13
  * - The createRemotePersister function returns a Persister that uses a remote
14
- * endpoint
14
+ * server.
15
15
  * - The createFilePersister function returns a Persister that uses a local file
16
- * (in an appropriate environment)
16
+ * (in an appropriate environment).
17
17
  *
18
18
  * Since persistence requirements can be different for every app, the
19
19
  * createCustomPersister function can also be used to easily create a fully
20
20
  * customized way to save and load Store data.
21
21
  *
22
+ * @see Persisting Data guide
23
+ * @see Countries demo
24
+ * @see Todo App demos
25
+ * @see TinyDraw demo
22
26
  * @packageDocumentation
23
27
  * @module persisters
24
28
  */
25
29
 
26
30
  import {Store, Tables} from './store.d';
27
- import {Callback} from './common';
31
+ import {Callback} from './common.d';
28
32
 
29
33
  /**
30
34
  * The PersisterStats type describes the number of times a Persister object has
@@ -89,7 +93,7 @@ export type PersisterStats = {
89
93
  * a JSON string, changes the persisted data, updates the Store from it, and
90
94
  * finally destroys the Persister again.
91
95
  *
92
- * ```tsx
96
+ * ```js
93
97
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
94
98
  * const persister = createSessionPersister(store, 'pets');
95
99
  *
@@ -110,7 +114,7 @@ export type PersisterStats = {
110
114
  * browser's session storage as a JSON string. Changes to the Store data, or the
111
115
  * persisted data (implicitly firing a StorageEvent), are reflected accordingly.
112
116
  *
113
- * ```tsx
117
+ * ```js
114
118
  * const store = createStore();
115
119
  * const persister = createSessionPersister(store, 'pets');
116
120
  *
@@ -133,6 +137,7 @@ export type PersisterStats = {
133
137
  * persister.destroy();
134
138
  * sessionStorage.clear();
135
139
  * ```
140
+ * @category Persister
136
141
  */
137
142
  export interface Persister {
138
143
  /**
@@ -158,7 +163,7 @@ export interface Persister {
158
163
  * browser's session storage, which for the purposes of this example has been
159
164
  * previously populated.
160
165
  *
161
- * ```tsx
166
+ * ```js
162
167
  * sessionStorage.setItem('pets', '{"pets":{"fido":{"species":"dog"}}}');
163
168
  *
164
169
  * const store = createStore();
@@ -176,7 +181,7 @@ export interface Persister {
176
181
  * parameter is used. The second time the load method is called, data has
177
182
  * previously been persisted and instead, that is loaded.
178
183
  *
179
- * ```tsx
184
+ * ```js
180
185
  * const store = createStore();
181
186
  * const persister = createSessionPersister(store, 'pets');
182
187
  *
@@ -226,7 +231,7 @@ export interface Persister {
226
231
  * reflected in the Store (in this case through detection of StorageEvents
227
232
  * from session storage changes made in another browser tab).
228
233
  *
229
- * ```tsx
234
+ * ```js
230
235
  * const store = createStore();
231
236
  * const persister = createSessionPersister(store, 'pets');
232
237
  *
@@ -242,6 +247,7 @@ export interface Persister {
242
247
  * console.log(store.getTables());
243
248
  * // -> {pets: {toto: {species: 'dog'}}}
244
249
  *
250
+ * persister.destroy();
245
251
  * sessionStorage.clear();
246
252
  * ```
247
253
  * @category Load
@@ -261,7 +267,7 @@ export interface Persister {
261
267
  * into it from the browser's session storage. Once the automatic loading is
262
268
  * stopped, subsequent changes are not reflected in the Store.
263
269
  *
264
- * ```tsx
270
+ * ```js
265
271
  * const store = createStore();
266
272
  * const persister = createSessionPersister(store, 'pets');
267
273
  * await persister.startAutoLoad();
@@ -283,6 +289,7 @@ export interface Persister {
283
289
  * // -> {pets: {toto: {species: 'dog'}}}
284
290
  * // Storage change has not been automatically loaded.
285
291
  *
292
+ * persister.destroy();
286
293
  * sessionStorage.clear();
287
294
  * ```
288
295
  * @category Load
@@ -303,7 +310,7 @@ export interface Persister {
303
310
  * This example creates a Store with some data, and saves into the browser's
304
311
  * session storage.
305
312
  *
306
- * ```tsx
313
+ * ```js
307
314
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
308
315
  * const persister = createSessionPersister(store, 'pets');
309
316
  *
@@ -314,6 +321,7 @@ export interface Persister {
314
321
  * persister.destroy();
315
322
  * sessionStorage.clear();
316
323
  * ```
324
+ * @category Save
317
325
  */
318
326
  save(): Promise<Persister>;
319
327
 
@@ -336,7 +344,7 @@ export interface Persister {
336
344
  * session storage. Subsequent changes to the Store are then automatically
337
345
  * saved to the underlying storage.
338
346
  *
339
- * ```tsx
347
+ * ```js
340
348
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
341
349
  * const persister = createSessionPersister(store, 'pets');
342
350
  *
@@ -351,6 +359,7 @@ export interface Persister {
351
359
  *
352
360
  * sessionStorage.clear();
353
361
  * ```
362
+ * @category Save
354
363
  */
355
364
  startAutoSave(): Promise<Persister>;
356
365
 
@@ -368,7 +377,7 @@ export interface Persister {
368
377
  * saved to the underlying storage. Once the automatic saving is
369
378
  * stopped, subsequent changes are not reflected.
370
379
  *
371
- * ```tsx
380
+ * ```js
372
381
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
373
382
  * const persister = createSessionPersister(store, 'pets');
374
383
  * await persister.startAutoSave();
@@ -401,7 +410,7 @@ export interface Persister {
401
410
  * This example creates a Persister object against a newly-created Store and
402
411
  * then gets its reference in order to update its data.
403
412
  *
404
- * ```tsx
413
+ * ```js
405
414
  * const persister = createSessionPersister(createStore(), 'pets');
406
415
  * await persister.startAutoSave();
407
416
  *
@@ -430,7 +439,7 @@ export interface Persister {
430
439
  * registers a TablesListener with the underlying Store), and then destroys it
431
440
  * again, removing the listener.
432
441
  *
433
- * ```tsx
442
+ * ```js
434
443
  * const store = createStore();
435
444
  * const persister = createSessionPersister(store, 'pets');
436
445
  * await persister.startAutoSave();
@@ -468,7 +477,7 @@ export interface Persister {
468
477
  * starts - so those numbers are included in addition to the loads and saves
469
478
  * invoked by changes to the Store and to the underlying storage.
470
479
  *
471
- * ```tsx
480
+ * ```js
472
481
  * const store = createStore();
473
482
  * const persister = createSessionPersister(store, 'pets');
474
483
  *
@@ -493,16 +502,114 @@ export interface Persister {
493
502
  getStats(): PersisterStats;
494
503
  }
495
504
 
505
+ /**
506
+ * The createSessionPersister function creates an Persister object that can
507
+ * persist the Store to the browser's session storage.
508
+ *
509
+ * As well as providing a reference to the Store to persist, you must provide a
510
+ * `storageName` parameter which is unique to your application. This is the key
511
+ * that the browser uses to identify the storage location.
512
+ *
513
+ * @param store The Store to persist.
514
+ * @param storageName The unique key to identify the storage location.
515
+ * @returns A reference to the new Persister object.
516
+ * @example
517
+ * This example creates a Persister object and persists the Store to the
518
+ * browser's session storage.
519
+ *
520
+ * ```js
521
+ * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
522
+ * const persister = createSessionPersister(store, 'pets');
523
+ *
524
+ * await persister.save();
525
+ * console.log(sessionStorage.getItem('pets'));
526
+ * // -> '{"pets":{"fido":{"species":"dog"}}}'
527
+ *
528
+ * persister.destroy();
529
+ * sessionStorage.clear();
530
+ * ```
531
+ * @category Creation
532
+ */
496
533
  export function createSessionPersister(
497
534
  store: Store,
498
535
  storageName: string,
499
536
  ): Persister;
500
537
 
538
+ /**
539
+ * The createLocalPersister function creates an Persister object that can
540
+ * persist the Store to the browser's local storage.
541
+ *
542
+ * As well as providing a reference to the Store to persist, you must provide a
543
+ * `storageName` parameter which is unique to your application. This is the key
544
+ * that the browser uses to identify the storage location.
545
+ *
546
+ * @param store The Store to persist.
547
+ * @param storageName The unique key to identify the storage location.
548
+ * @returns A reference to the new Persister object.
549
+ * @example
550
+ * This example creates a Persister object and persists the Store to the
551
+ * browser's local storage.
552
+ *
553
+ * ```js
554
+ * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
555
+ * const persister = createLocalPersister(store, 'pets');
556
+ *
557
+ * await persister.save();
558
+ * console.log(localStorage.getItem('pets'));
559
+ * // -> '{"pets":{"fido":{"species":"dog"}}}'
560
+ *
561
+ * persister.destroy();
562
+ * localStorage.clear();
563
+ * ```
564
+ * @category Creation
565
+ */
501
566
  export function createLocalPersister(
502
567
  store: Store,
503
568
  storageName: string,
504
569
  ): Persister;
505
570
 
571
+ /**
572
+ * The createRemotePersister function creates an Persister object that can
573
+ * persist the Store to a remote server.
574
+ *
575
+ * As well as providing a reference to the Store to persist, you must provide
576
+ * `loadUrl` and `saveUrl` parameters. These identify the endpoints of the
577
+ * server that support the `GET` method (to fetch the Store JSON to load) and
578
+ * the `POST` method (to send the Store JSON to save) respectively.
579
+ *
580
+ * For when you choose to enable automatic loading for the Persister (with the
581
+ * startAutoLoad method), it will poll the loadUrl for changes. The
582
+ * `autoLoadIntervalSeconds` method is used to indicate how often to do this.
583
+ *
584
+ * @param store The Store to persist.
585
+ * @param loadUrl The endpoint that supports a `GET` method to load JSON.
586
+ * @param saveUrl The endpoint that supports a `POST` method to save JSON.
587
+ * @param autoLoadIntervalSeconds How often to poll the `loadUrl` when
588
+ * automatically loading changes from the server.
589
+ * @returns A reference to the new Persister object.
590
+ * @example
591
+ * This example creates a Persister object and persists the Store to a remote
592
+ * server.
593
+ *
594
+ * ```js yolo
595
+ * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
596
+ * const persister = createRemotePersister(
597
+ * store,
598
+ * 'https://example.com/load',
599
+ * 'https://example.com/save',
600
+ * 5,
601
+ * );
602
+ *
603
+ * await persister.save();
604
+ * // Store JSON will be sent to server in a POST request.
605
+ *
606
+ * await persister.load();
607
+ * // Store JSON will be fetched from server with a GET request.
608
+ *
609
+ * persister.destroy();
610
+ * ```
611
+ * @category Creation
612
+ */
506
613
  export function createRemotePersister(
507
614
  store: Store,
508
615
  loadUrl: string,
@@ -510,8 +617,91 @@ export function createRemotePersister(
510
617
  autoLoadIntervalSeconds: number,
511
618
  ): Persister;
512
619
 
620
+ /**
621
+ * The createFilePersister function creates an Persister object that can persist
622
+ * the Store to a local file (in an appropriate environment).
623
+ *
624
+ * As well as providing a reference to the Store to persist, you must provide
625
+ * `filePath` parameter which identifies the file to persist it to.
626
+ *
627
+ * @param store The Store to persist.
628
+ * @param filePath The location of the local file to persist the Store to.
629
+ * @returns A reference to the new Persister object.
630
+ * @example
631
+ * This example creates a Persister object and persists the Store to a local
632
+ * file.
633
+ *
634
+ * ```js yolo
635
+ * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
636
+ * const persister = createFilePersister(store, '/app/persisted.json');
637
+ *
638
+ * await persister.save();
639
+ * // Store JSON will be saved to the file.
640
+ *
641
+ * await persister.load();
642
+ * // Store JSON will be loaded from the file.
643
+ *
644
+ * persister.destroy();
645
+ * ```
646
+ * @category Creation
647
+ */
513
648
  export function createFilePersister(store: Store, filePath: string): Persister;
514
649
 
650
+ /**
651
+ * The createCustomPersister function creates an Persister object that you can
652
+ * configure to persist the Store in any way you wish.
653
+ *
654
+ * As well as providing a reference to the Store to persist, you must provide
655
+ * functions that handle how to fetch, write, and listen to, the persistence
656
+ * layer.
657
+ *
658
+ * The other creation functions (such as the createSessionPersister function and
659
+ * createFilePersister function, for example) all use this function under the
660
+ * covers. See those implementations for ideas on how to implement your own
661
+ * Persister types.
662
+ *
663
+ * @param store The Store to persist.
664
+ * @param getPersisted An asynchronous function which will fetch JSON from the
665
+ * persistence layer (or `null` or `undefined` if not present).
666
+ * @param setPersisted An asynchronous function which will send JSON to the
667
+ * persistence layer.
668
+ * @param startListeningToPersisted A function that will register a `didChange`
669
+ * listener on underlying changes to the persistence layer.
670
+ * @param stopListeningToPersisted A function that will unregister the listener
671
+ * from the underlying changes to the persistence layer.
672
+ * @returns A reference to the new Persister object.
673
+ * @example
674
+ * This example creates a custom Persister object and persists the Store to a
675
+ * local string called `storeJson` and which would automatically load by polling
676
+ * for changes every second.
677
+ *
678
+ * ```js
679
+ * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
680
+ * let storeJson;
681
+ * let interval;
682
+ *
683
+ * const persister = createCustomPersister(
684
+ * store,
685
+ * async () => storeJson,
686
+ * async (json) => (storeJson = json),
687
+ * (didChange) => (interval = setInterval(didChange, 1000)),
688
+ * () => clearInterval(interval),
689
+ * );
690
+ *
691
+ * await persister.save();
692
+ * console.log(storeJson);
693
+ * // -> '{"pets":{"fido":{"species":"dog"}}}'
694
+ *
695
+ * storeJson = '{"pets":{"fido":{"species":"dog","color":"brown"}}}';
696
+ * await persister.load();
697
+ *
698
+ * console.log(store.getTables());
699
+ * // -> {pets: {fido: {species: 'dog', color: 'brown'}}}
700
+ *
701
+ * persister.destroy();
702
+ * ```
703
+ * @category Creation
704
+ */
515
705
  export function createCustomPersister(
516
706
  store: Store,
517
707
  getPersisted: () => Promise<string | null | undefined>,
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * The main entry point to this module is the createRelationships function,
6
6
  * which returns a new Relationships object. From there, you can create new
7
- * relationship definitions, access the associations within those relationships
7
+ * Relationship definitions, access the associations within those Relationships
8
8
  * directly, and register listeners for when they change.
9
9
  *
10
10
  * @packageDocumentation
@@ -50,6 +50,9 @@ export type Relationship = {
50
50
  * object, the Id of the Relationship that changed, and the Id of the local Row
51
51
  * whose remote Row Id changed.
52
52
  *
53
+ * @param relationships A reference to the Relationships object that changed.
54
+ * @param relationshipId The Id of the Relationship that changed.
55
+ * @param localRowId The Id of the local Row whose remote Row Id changed.
53
56
  * @category Listener
54
57
  */
55
58
  export type RemoteRowIdListener = (
@@ -67,8 +70,11 @@ export type RemoteRowIdListener = (
67
70
  *
68
71
  * When called, a LocalRowIdsListener is given a reference to the Relationships
69
72
  * object, the Id of the Relationship that changed, and the Id of the remote Row
70
- * whose local Row Id changed.
73
+ * whose local Row Ids changed.
71
74
  *
75
+ * @param relationships A reference to the Relationships object that changed.
76
+ * @param relationshipId The Id of the Relationship that changed.
77
+ * @param remoteRowId The Id of the remote Row whose local Row Ids changed.
72
78
  * @category Listener
73
79
  */
74
80
  export type LocalRowIdsListener = (
@@ -88,6 +94,10 @@ export type LocalRowIdsListener = (
88
94
  * object, the Id of the Relationship that changed, and the Id of the first Row
89
95
  * of the the linked list whose members changed.
90
96
  *
97
+ * @param relationships A reference to the Relationships object that changed.
98
+ * @param relationshipId The Id of the Relationship that changed.
99
+ * @param firstRowId The Id of the first Row of the the linked list whose
100
+ * members changed.
91
101
  * @category Listener
92
102
  */
93
103
  export type LinkedRowIdsListener = (
@@ -107,8 +117,19 @@ export type LinkedRowIdsListener = (
107
117
  * @category Development
108
118
  */
109
119
  export type RelationshipsListenerStats = {
120
+ /**
121
+ * The number of RemoteRowIdListeners registered with the Relationships
122
+ * object.
123
+ */
110
124
  remoteRowId?: number;
125
+ /**
126
+ * The number of LocalRowIdsListeners registered with the Relationships
127
+ * object.
128
+ */
111
129
  localRowIds?: number;
130
+ /**
131
+ * The number of LinkedRowIds registered with the Relationships object.
132
+ */
112
133
  linkedRowIds?: number;
113
134
  };
114
135
 
@@ -137,7 +158,7 @@ export type RelationshipsListenerStats = {
137
158
  * creation, to adding definitions (both local/remote table and linked list),
138
159
  * getting their contents, and then registering and removing listeners for them.
139
160
  *
140
- * ```tsx
161
+ * ```js
141
162
  * const store = createStore()
142
163
  * .setTable('pets', {
143
164
  * fido: {species: 'dog', next: 'felix'},
@@ -201,6 +222,9 @@ export type RelationshipsListenerStats = {
201
222
  * relationships.delListener(listenerId2);
202
223
  * relationships.destroy();
203
224
  * ```
225
+ * @see Relationships And Checkpoints guides
226
+ * @see TinyDraw demo
227
+ * @category Relationships
204
228
  */
205
229
  export interface Relationships {
206
230
  /**
@@ -239,7 +263,7 @@ export interface Relationships {
239
263
  * a simple Relationship based on the values in the `species` Cell of the
240
264
  * `pets` Table that relates a Row to another in the `species` Table.
241
265
  *
242
- * ```tsx
266
+ * ```js
243
267
  * const store = createStore()
244
268
  * .setTable('pets', {
245
269
  * fido: {species: 'dog'},
@@ -269,7 +293,7 @@ export interface Relationships {
269
293
  * a linked list Relationship based on the values in the `next` Cell of the
270
294
  * `pets` Table that relates a Row to another in the same Table.
271
295
  *
272
- * ```tsx
296
+ * ```js
273
297
  * const store = createStore().setTable('pets', {
274
298
  * fido: {species: 'dog', next: 'felix'},
275
299
  * felix: {species: 'cat', next: 'cujo'},
@@ -306,7 +330,7 @@ export interface Relationships {
306
330
  * This example creates a Store, creates a Relationships object, defines a
307
331
  * simple Relationship, and then removes it.
308
332
  *
309
- * ```tsx
333
+ * ```js
310
334
  * const store = createStore()
311
335
  * .setTable('pets', {
312
336
  * fido: {species: 'dog'},
@@ -345,7 +369,7 @@ export interface Relationships {
345
369
  * This example creates a Relationships object against a newly-created Store
346
370
  * and then gets its reference in order to update its data.
347
371
  *
348
- * ```tsx
372
+ * ```js
349
373
  * const relationships = createRelationships(createStore());
350
374
  * relationships.setRelationshipDefinition(
351
375
  * 'petSpecies',
@@ -370,7 +394,7 @@ export interface Relationships {
370
394
  * This example creates a Relationships object with two definitions, and then
371
395
  * gets the Ids of the definitions.
372
396
  *
373
- * ```tsx
397
+ * ```js
374
398
  * const relationships = createRelationships(createStore())
375
399
  * .setRelationshipDefinition('petSpecies', 'pets', 'species', 'species')
376
400
  * .setRelationshipDefinition('petSequence', 'pets', 'pets', 'next');
@@ -395,7 +419,7 @@ export interface Relationships {
395
419
  * definition, and then queries it (and a non-existent definition) to get the
396
420
  * underlying local Table Id.
397
421
  *
398
- * ```tsx
422
+ * ```js
399
423
  * const relationships = createRelationships(createStore());
400
424
  * relationships.setRelationshipDefinition(
401
425
  * 'petSpecies',
@@ -427,7 +451,7 @@ export interface Relationships {
427
451
  * definition, and then queries it (and a non-existent definition) to get the
428
452
  * underlying remote Table Id.
429
453
  *
430
- * ```tsx
454
+ * ```js
431
455
  * const relationships = createRelationships(createStore());
432
456
  * relationships.setRelationshipDefinition(
433
457
  * 'petSpecies',
@@ -461,7 +485,7 @@ export interface Relationships {
461
485
  * in the Relationship (and also the remote Row Ids for a local Row that does
462
486
  * not exist, and for a Relationship that has not been defined).
463
487
  *
464
- * ```tsx
488
+ * ```js
465
489
  * const store = createStore()
466
490
  * .setTable('pets', {
467
491
  * fido: {species: 'dog'},
@@ -508,7 +532,7 @@ export interface Relationships {
508
532
  * in the Relationship (and also the local Row Ids for a remote Row that does
509
533
  * not exist, and for a Relationship that has not been defined).
510
534
  *
511
- * ```tsx
535
+ * ```js
512
536
  * const store = createStore()
513
537
  * .setTable('pets', {
514
538
  * fido: {species: 'dog'},
@@ -560,7 +584,7 @@ export interface Relationships {
560
584
  * linked Row Ids in the Relationship (and also the linked Row Ids for a Row
561
585
  * that does not exist, and for a Relationship that has not been defined).
562
586
  *
563
- * ```tsx
587
+ * ```js
564
588
  * const store = createStore().setTable('pets', {
565
589
  * fido: {species: 'dog', next: 'felix'},
566
590
  * felix: {species: 'cat', next: 'cujo'},
@@ -618,7 +642,7 @@ export interface Relationships {
618
642
  * This example creates a Store, a Relationships object, and then registers a
619
643
  * listener that responds to any changes to a specific local Row's remote Row.
620
644
  *
621
- * ```tsx
645
+ * ```js
622
646
  * const store = createStore()
623
647
  * .setTable('pets', {
624
648
  * fido: {species: 'dog'},
@@ -660,7 +684,7 @@ export interface Relationships {
660
684
  * also illustrates how you can use the getStore method and the getRemoteRowId
661
685
  * method to resolve the remote Row as a whole.
662
686
  *
663
- * ```tsx
687
+ * ```js
664
688
  * const store = createStore()
665
689
  * .setTable('pets', {
666
690
  * fido: {species: 'dog', color: 'brown'},
@@ -750,7 +774,7 @@ export interface Relationships {
750
774
  * listener that responds to any changes to a specific remote Row's local Row
751
775
  * objects.
752
776
  *
753
- * ```tsx
777
+ * ```js
754
778
  * const store = createStore()
755
779
  * .setTable('pets', {
756
780
  * fido: {species: 'dog'},
@@ -791,7 +815,7 @@ export interface Relationships {
791
815
  * listener that responds to any changes to any remote Row's local Row
792
816
  * objects.
793
817
  *
794
- * ```tsx
818
+ * ```js
795
819
  * const store = createStore()
796
820
  * .setTable('pets', {
797
821
  * fido: {species: 'dog', color: 'brown'},
@@ -877,7 +901,7 @@ export interface Relationships {
877
901
  * listener that responds to any changes to a specific first Row's linked Row
878
902
  * objects.
879
903
  *
880
- * ```tsx
904
+ * ```js
881
905
  * const store = createStore().setTable('pets', {
882
906
  * fido: {species: 'dog', next: 'felix'},
883
907
  * felix: {species: 'cat', next: 'cujo'},
@@ -930,7 +954,7 @@ export interface Relationships {
930
954
  * This example creates a Store, a Relationships object, registers a listener,
931
955
  * and then removes it.
932
956
  *
933
- * ```tsx
957
+ * ```js
934
958
  * const store = createStore()
935
959
  * .setTable('pets', {
936
960
  * fido: {species: 'dog'},
@@ -984,7 +1008,7 @@ export interface Relationships {
984
1008
  * definition (that registers a RowListener with the underlying Store),
985
1009
  * and then destroys it again, removing the listener.
986
1010
  *
987
- * ```tsx
1011
+ * ```js
988
1012
  * const store = createStore()
989
1013
  * .setTable('pets', {
990
1014
  * fido: {species: 'dog'},
@@ -1034,7 +1058,7 @@ export interface Relationships {
1034
1058
  * @example
1035
1059
  * This example gets the listener statistics of a Relationships object.
1036
1060
  *
1037
- * ```tsx
1061
+ * ```js
1038
1062
  * const store = createStore();
1039
1063
  * const relationships = createRelationships(store);
1040
1064
  * relationships.addRemoteRowIdListener(null, null, () => {
@@ -1070,7 +1094,7 @@ export interface Relationships {
1070
1094
  * @example
1071
1095
  * This example creates an Relationships object.
1072
1096
  *
1073
- * ```tsx
1097
+ * ```js
1074
1098
  * const store = createStore();
1075
1099
  * const relationships = createRelationships(store);
1076
1100
  * console.log(relationships.getRelationshipIds());
@@ -1080,12 +1104,13 @@ export interface Relationships {
1080
1104
  * This example creates a Relationships object, and calls the method a second
1081
1105
  * time for the same Store to return the same object.
1082
1106
  *
1083
- * ```tsx
1107
+ * ```js
1084
1108
  * const store = createStore();
1085
1109
  * const relationships1 = createRelationships(store);
1086
1110
  * const relationships2 = createRelationships(store);
1087
1111
  * console.log(relationships1 === relationships2);
1088
1112
  * // -> true
1089
1113
  * ```
1114
+ * @category Creation
1090
1115
  */
1091
1116
  export function createRelationships(store: Store): Relationships;