TinyBase logoTinyBase β

getMergeableRowHashes

The getMergeableRowHashes method returns hashes for Row objects in a MergeableStore.

getMergeableRowHashes(otherTableHashes: TableHashes): RowHashes
TypeDescription
otherTableHashesTableHashes

The TableHashes from the other MergeableStore so that the differences can be efficiently identified.

returnsRowHashes

A RowHashes object with the hashes of each Row in the relevant Table objects of the MergeableStore.

If two Row Ids have different hashes, that indicates that the content within them is different and should be synchronized.

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 a MergeableStore, sets some data, and then accesses the Row hashes for the differing Table Ids.

import {createMergeableStore} from 'tinybase';

const store1 = createMergeableStore('store1');
store1.setTables({pets: {fido: {color: 'brown'}, felix: {color: 'tan'}}});

const store2 = createMergeableStore('store2');
store2.setTables({pets: {fido: {color: 'black'}, felix: {color: 'tan'}}});

console.log(
  store1.getMergeableRowHashes(
    store2.getMergeableTableDiff(store1.getMergeableTableHashes())[1],
  ),
);
// -> {pets: {felix: 1683761402, fido: 851131566}}

Since

v5.0.0