getMergeableTableDiff
The getMergeableTableDiff
method returns information about new and differing Table
objects of a MergeableStore
relative to another.
getMergeableTableDiff(otherTableHashes: TableHashes): [newTables: [thing: {[tableId: Id]: TableStamp<Hashed>}, time?: string], differingTableHashes: TableHashes]
Type | Description | |
---|---|---|
otherTableHashes | TableHashes | The |
returns | [newTables: [thing: {[tableId: Id]: TableStamp<Hashed>}, time?: string], differingTableHashes: TableHashes] | A pair of objects describing the new and differing |
The method is generally intended to be used internally within TinyBase itself and the return type is assumed to be opaque to applications that use it.
Example
This example creates two MergeableStores, sets some differing data, and then identifies the differences in the Table
objects of one versus the other. Once they have been merged, the differences are empty.
import {createMergeableStore} from 'tinybase';
const store1 = createMergeableStore('store1');
store1.setTables({pets: {fido: {color: 'brown'}}});
const store2 = createMergeableStore('store2');
store2.setTables({
pets: {fido: {species: 'dog'}},
species: {dog: {price: 5}},
});
console.log(
store2.getMergeableTableDiff(store1.getMergeableTableHashes()),
);
// ->
[
[{species: [{dog: [{price: [5, 'Nn1JUF----0CnH-J']}]}]}],
{pets: 1212600658},
];
store1.merge(store2);
console.log(
store2.getMergeableTableDiff(store1.getMergeableTableHashes()),
);
// -> [[{}], {}]
Since
v5.0.0